diff --git a/sdk/appplatform/azure-mgmt-appplatform/_meta.json b/sdk/appplatform/azure-mgmt-appplatform/_meta.json index f2fe624defba..0205050d0f07 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/_meta.json +++ b/sdk/appplatform/azure-mgmt-appplatform/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "commit": "d4d8c629d35c22ed932fce547f3ccdfda1368697", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.13.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.2.1", + "@autorest/modelerfour@4.24.3" ], - "commit": "0cc5e2efd6ffccf30e80d1e150b488dd87198b94", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/appplatform/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/appplatform/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.2.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/appplatform/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/__init__.py index 9c5da1ef39d0..8ac89fff836f 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/_app_platform_management_client.py index 1497bb5f1501..eacf0ed8fe9c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/_app_platform_management_client.py @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from ._configuration import AppPlatformManagementClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -43,9 +40,9 @@ class AppPlatformManagementClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -67,10 +64,10 @@ class AppPlatformManagementClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): @@ -97,6 +94,8 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2022-03-01-preview: :mod:`v2022_03_01_preview.models` * 2022-04-01: :mod:`v2022_04_01.models` * 2022-05-01-preview: :mod:`v2022_05_01_preview.models` + * 2022-09-01-preview: :mod:`v2022_09_01_preview.models` + * 2022-11-01-preview: :mod:`v2022_11_01_preview.models` """ if api_version == '2020-07-01': from .v2020_07_01 import models @@ -122,6 +121,12 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-05-01-preview': from .v2022_05_01_preview import models return models + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview import models + return models + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -131,6 +136,8 @@ def api_portal_custom_domains(self): * 2022-01-01-preview: :class:`ApiPortalCustomDomainsOperations` * 2022-03-01-preview: :class:`ApiPortalCustomDomainsOperations` * 2022-05-01-preview: :class:`ApiPortalCustomDomainsOperations` + * 2022-09-01-preview: :class:`ApiPortalCustomDomainsOperations` + * 2022-11-01-preview: :class:`ApiPortalCustomDomainsOperations` """ api_version = self._get_api_version('api_portal_custom_domains') if api_version == '2022-01-01-preview': @@ -139,8 +146,13 @@ def api_portal_custom_domains(self): from .v2022_03_01_preview.operations import ApiPortalCustomDomainsOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import ApiPortalCustomDomainsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import ApiPortalCustomDomainsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import ApiPortalCustomDomainsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'api_portal_custom_domains'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -150,6 +162,8 @@ def api_portals(self): * 2022-01-01-preview: :class:`ApiPortalsOperations` * 2022-03-01-preview: :class:`ApiPortalsOperations` * 2022-05-01-preview: :class:`ApiPortalsOperations` + * 2022-09-01-preview: :class:`ApiPortalsOperations` + * 2022-11-01-preview: :class:`ApiPortalsOperations` """ api_version = self._get_api_version('api_portals') if api_version == '2022-01-01-preview': @@ -158,8 +172,41 @@ def api_portals(self): from .v2022_03_01_preview.operations import ApiPortalsOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import ApiPortalsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import ApiPortalsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import ApiPortalsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'api_portals'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def application_accelerators(self): + """Instance depends on the API version: + + * 2022-11-01-preview: :class:`ApplicationAcceleratorsOperations` + """ + api_version = self._get_api_version('application_accelerators') + if api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import ApplicationAcceleratorsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'application_accelerators'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def application_live_views(self): + """Instance depends on the API version: + + * 2022-11-01-preview: :class:`ApplicationLiveViewsOperations` + """ + api_version = self._get_api_version('application_live_views') + if api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import ApplicationLiveViewsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'application_live_views'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -174,6 +221,8 @@ def apps(self): * 2022-03-01-preview: :class:`AppsOperations` * 2022-04-01: :class:`AppsOperations` * 2022-05-01-preview: :class:`AppsOperations` + * 2022-09-01-preview: :class:`AppsOperations` + * 2022-11-01-preview: :class:`AppsOperations` """ api_version = self._get_api_version('apps') if api_version == '2020-07-01': @@ -192,8 +241,13 @@ def apps(self): from .v2022_04_01.operations import AppsOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import AppsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import AppsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import AppsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'apps'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -208,6 +262,8 @@ def bindings(self): * 2022-03-01-preview: :class:`BindingsOperations` * 2022-04-01: :class:`BindingsOperations` * 2022-05-01-preview: :class:`BindingsOperations` + * 2022-09-01-preview: :class:`BindingsOperations` + * 2022-11-01-preview: :class:`BindingsOperations` """ api_version = self._get_api_version('bindings') if api_version == '2020-07-01': @@ -226,8 +282,13 @@ def bindings(self): from .v2022_04_01.operations import BindingsOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import BindingsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import BindingsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import BindingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'bindings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -238,6 +299,8 @@ def build_service(self): * 2022-03-01-preview: :class:`BuildServiceOperations` * 2022-04-01: :class:`BuildServiceOperations` * 2022-05-01-preview: :class:`BuildServiceOperations` + * 2022-09-01-preview: :class:`BuildServiceOperations` + * 2022-11-01-preview: :class:`BuildServiceOperations` """ api_version = self._get_api_version('build_service') if api_version == '2022-01-01-preview': @@ -248,8 +311,13 @@ def build_service(self): from .v2022_04_01.operations import BuildServiceOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import BuildServiceOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import BuildServiceOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import BuildServiceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'build_service'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -260,6 +328,8 @@ def build_service_agent_pool(self): * 2022-03-01-preview: :class:`BuildServiceAgentPoolOperations` * 2022-04-01: :class:`BuildServiceAgentPoolOperations` * 2022-05-01-preview: :class:`BuildServiceAgentPoolOperations` + * 2022-09-01-preview: :class:`BuildServiceAgentPoolOperations` + * 2022-11-01-preview: :class:`BuildServiceAgentPoolOperations` """ api_version = self._get_api_version('build_service_agent_pool') if api_version == '2022-01-01-preview': @@ -270,8 +340,13 @@ def build_service_agent_pool(self): from .v2022_04_01.operations import BuildServiceAgentPoolOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import BuildServiceAgentPoolOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import BuildServiceAgentPoolOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import BuildServiceAgentPoolOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'build_service_agent_pool'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -282,6 +357,8 @@ def build_service_builder(self): * 2022-03-01-preview: :class:`BuildServiceBuilderOperations` * 2022-04-01: :class:`BuildServiceBuilderOperations` * 2022-05-01-preview: :class:`BuildServiceBuilderOperations` + * 2022-09-01-preview: :class:`BuildServiceBuilderOperations` + * 2022-11-01-preview: :class:`BuildServiceBuilderOperations` """ api_version = self._get_api_version('build_service_builder') if api_version == '2022-01-01-preview': @@ -292,8 +369,13 @@ def build_service_builder(self): from .v2022_04_01.operations import BuildServiceBuilderOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import BuildServiceBuilderOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import BuildServiceBuilderOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import BuildServiceBuilderOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'build_service_builder'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -304,6 +386,8 @@ def buildpack_binding(self): * 2022-03-01-preview: :class:`BuildpackBindingOperations` * 2022-04-01: :class:`BuildpackBindingOperations` * 2022-05-01-preview: :class:`BuildpackBindingOperations` + * 2022-09-01-preview: :class:`BuildpackBindingOperations` + * 2022-11-01-preview: :class:`BuildpackBindingOperations` """ api_version = self._get_api_version('buildpack_binding') if api_version == '2022-01-01-preview': @@ -314,8 +398,13 @@ def buildpack_binding(self): from .v2022_04_01.operations import BuildpackBindingOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import BuildpackBindingOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import BuildpackBindingOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import BuildpackBindingOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'buildpack_binding'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -330,6 +419,8 @@ def certificates(self): * 2022-03-01-preview: :class:`CertificatesOperations` * 2022-04-01: :class:`CertificatesOperations` * 2022-05-01-preview: :class:`CertificatesOperations` + * 2022-09-01-preview: :class:`CertificatesOperations` + * 2022-11-01-preview: :class:`CertificatesOperations` """ api_version = self._get_api_version('certificates') if api_version == '2020-07-01': @@ -348,8 +439,13 @@ def certificates(self): from .v2022_04_01.operations import CertificatesOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import CertificatesOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import CertificatesOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import CertificatesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'certificates'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -364,6 +460,8 @@ def config_servers(self): * 2022-03-01-preview: :class:`ConfigServersOperations` * 2022-04-01: :class:`ConfigServersOperations` * 2022-05-01-preview: :class:`ConfigServersOperations` + * 2022-09-01-preview: :class:`ConfigServersOperations` + * 2022-11-01-preview: :class:`ConfigServersOperations` """ api_version = self._get_api_version('config_servers') if api_version == '2020-07-01': @@ -382,8 +480,13 @@ def config_servers(self): from .v2022_04_01.operations import ConfigServersOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import ConfigServersOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import ConfigServersOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import ConfigServersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'config_servers'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -394,6 +497,8 @@ def configuration_services(self): * 2022-03-01-preview: :class:`ConfigurationServicesOperations` * 2022-04-01: :class:`ConfigurationServicesOperations` * 2022-05-01-preview: :class:`ConfigurationServicesOperations` + * 2022-09-01-preview: :class:`ConfigurationServicesOperations` + * 2022-11-01-preview: :class:`ConfigurationServicesOperations` """ api_version = self._get_api_version('configuration_services') if api_version == '2022-01-01-preview': @@ -404,8 +509,13 @@ def configuration_services(self): from .v2022_04_01.operations import ConfigurationServicesOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import ConfigurationServicesOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import ConfigurationServicesOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import ConfigurationServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'configuration_services'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -420,6 +530,8 @@ def custom_domains(self): * 2022-03-01-preview: :class:`CustomDomainsOperations` * 2022-04-01: :class:`CustomDomainsOperations` * 2022-05-01-preview: :class:`CustomDomainsOperations` + * 2022-09-01-preview: :class:`CustomDomainsOperations` + * 2022-11-01-preview: :class:`CustomDomainsOperations` """ api_version = self._get_api_version('custom_domains') if api_version == '2020-07-01': @@ -438,8 +550,27 @@ def custom_domains(self): from .v2022_04_01.operations import CustomDomainsOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import CustomDomainsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import CustomDomainsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import CustomDomainsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'custom_domains'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def customized_accelerators(self): + """Instance depends on the API version: + + * 2022-11-01-preview: :class:`CustomizedAcceleratorsOperations` + """ + api_version = self._get_api_version('customized_accelerators') + if api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import CustomizedAcceleratorsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'customized_accelerators'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -454,6 +585,8 @@ def deployments(self): * 2022-03-01-preview: :class:`DeploymentsOperations` * 2022-04-01: :class:`DeploymentsOperations` * 2022-05-01-preview: :class:`DeploymentsOperations` + * 2022-09-01-preview: :class:`DeploymentsOperations` + * 2022-11-01-preview: :class:`DeploymentsOperations` """ api_version = self._get_api_version('deployments') if api_version == '2020-07-01': @@ -472,8 +605,27 @@ def deployments(self): from .v2022_04_01.operations import DeploymentsOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import DeploymentsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import DeploymentsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import DeploymentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'deployments'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def dev_tool_portals(self): + """Instance depends on the API version: + + * 2022-11-01-preview: :class:`DevToolPortalsOperations` + """ + api_version = self._get_api_version('dev_tool_portals') + if api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import DevToolPortalsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'dev_tool_portals'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -483,6 +635,8 @@ def gateway_custom_domains(self): * 2022-01-01-preview: :class:`GatewayCustomDomainsOperations` * 2022-03-01-preview: :class:`GatewayCustomDomainsOperations` * 2022-05-01-preview: :class:`GatewayCustomDomainsOperations` + * 2022-09-01-preview: :class:`GatewayCustomDomainsOperations` + * 2022-11-01-preview: :class:`GatewayCustomDomainsOperations` """ api_version = self._get_api_version('gateway_custom_domains') if api_version == '2022-01-01-preview': @@ -491,8 +645,13 @@ def gateway_custom_domains(self): from .v2022_03_01_preview.operations import GatewayCustomDomainsOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import GatewayCustomDomainsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import GatewayCustomDomainsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import GatewayCustomDomainsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'gateway_custom_domains'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -502,6 +661,8 @@ def gateway_route_configs(self): * 2022-01-01-preview: :class:`GatewayRouteConfigsOperations` * 2022-03-01-preview: :class:`GatewayRouteConfigsOperations` * 2022-05-01-preview: :class:`GatewayRouteConfigsOperations` + * 2022-09-01-preview: :class:`GatewayRouteConfigsOperations` + * 2022-11-01-preview: :class:`GatewayRouteConfigsOperations` """ api_version = self._get_api_version('gateway_route_configs') if api_version == '2022-01-01-preview': @@ -510,8 +671,13 @@ def gateway_route_configs(self): from .v2022_03_01_preview.operations import GatewayRouteConfigsOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import GatewayRouteConfigsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import GatewayRouteConfigsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import GatewayRouteConfigsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'gateway_route_configs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -521,6 +687,8 @@ def gateways(self): * 2022-01-01-preview: :class:`GatewaysOperations` * 2022-03-01-preview: :class:`GatewaysOperations` * 2022-05-01-preview: :class:`GatewaysOperations` + * 2022-09-01-preview: :class:`GatewaysOperations` + * 2022-11-01-preview: :class:`GatewaysOperations` """ api_version = self._get_api_version('gateways') if api_version == '2022-01-01-preview': @@ -529,8 +697,13 @@ def gateways(self): from .v2022_03_01_preview.operations import GatewaysOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import GatewaysOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import GatewaysOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import GatewaysOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'gateways'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -545,6 +718,8 @@ def monitoring_settings(self): * 2022-03-01-preview: :class:`MonitoringSettingsOperations` * 2022-04-01: :class:`MonitoringSettingsOperations` * 2022-05-01-preview: :class:`MonitoringSettingsOperations` + * 2022-09-01-preview: :class:`MonitoringSettingsOperations` + * 2022-11-01-preview: :class:`MonitoringSettingsOperations` """ api_version = self._get_api_version('monitoring_settings') if api_version == '2020-07-01': @@ -563,8 +738,13 @@ def monitoring_settings(self): from .v2022_04_01.operations import MonitoringSettingsOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import MonitoringSettingsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import MonitoringSettingsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import MonitoringSettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'monitoring_settings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -579,6 +759,8 @@ def operations(self): * 2022-03-01-preview: :class:`Operations` * 2022-04-01: :class:`Operations` * 2022-05-01-preview: :class:`Operations` + * 2022-09-01-preview: :class:`Operations` + * 2022-11-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2020-07-01': @@ -597,8 +779,27 @@ def operations(self): from .v2022_04_01.operations import Operations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import Operations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import Operations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def predefined_accelerators(self): + """Instance depends on the API version: + + * 2022-11-01-preview: :class:`PredefinedAcceleratorsOperations` + """ + api_version = self._get_api_version('predefined_accelerators') + if api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import PredefinedAcceleratorsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'predefined_accelerators'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -613,6 +814,8 @@ def runtime_versions(self): * 2022-03-01-preview: :class:`RuntimeVersionsOperations` * 2022-04-01: :class:`RuntimeVersionsOperations` * 2022-05-01-preview: :class:`RuntimeVersionsOperations` + * 2022-09-01-preview: :class:`RuntimeVersionsOperations` + * 2022-11-01-preview: :class:`RuntimeVersionsOperations` """ api_version = self._get_api_version('runtime_versions') if api_version == '2020-07-01': @@ -631,8 +834,13 @@ def runtime_versions(self): from .v2022_04_01.operations import RuntimeVersionsOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import RuntimeVersionsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import RuntimeVersionsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import RuntimeVersionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'runtime_versions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -643,6 +851,8 @@ def service_registries(self): * 2022-03-01-preview: :class:`ServiceRegistriesOperations` * 2022-04-01: :class:`ServiceRegistriesOperations` * 2022-05-01-preview: :class:`ServiceRegistriesOperations` + * 2022-09-01-preview: :class:`ServiceRegistriesOperations` + * 2022-11-01-preview: :class:`ServiceRegistriesOperations` """ api_version = self._get_api_version('service_registries') if api_version == '2022-01-01-preview': @@ -653,8 +863,13 @@ def service_registries(self): from .v2022_04_01.operations import ServiceRegistriesOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import ServiceRegistriesOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import ServiceRegistriesOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import ServiceRegistriesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'service_registries'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -669,6 +884,8 @@ def services(self): * 2022-03-01-preview: :class:`ServicesOperations` * 2022-04-01: :class:`ServicesOperations` * 2022-05-01-preview: :class:`ServicesOperations` + * 2022-09-01-preview: :class:`ServicesOperations` + * 2022-11-01-preview: :class:`ServicesOperations` """ api_version = self._get_api_version('services') if api_version == '2020-07-01': @@ -687,8 +904,13 @@ def services(self): from .v2022_04_01.operations import ServicesOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import ServicesOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import ServicesOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import ServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'services'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -703,6 +925,8 @@ def skus(self): * 2022-03-01-preview: :class:`SkusOperations` * 2022-04-01: :class:`SkusOperations` * 2022-05-01-preview: :class:`SkusOperations` + * 2022-09-01-preview: :class:`SkusOperations` + * 2022-11-01-preview: :class:`SkusOperations` """ api_version = self._get_api_version('skus') if api_version == '2020-07-01': @@ -721,8 +945,13 @@ def skus(self): from .v2022_04_01.operations import SkusOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import SkusOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import SkusOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import SkusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'skus'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -733,6 +962,8 @@ def storages(self): * 2022-01-01-preview: :class:`StoragesOperations` * 2022-03-01-preview: :class:`StoragesOperations` * 2022-05-01-preview: :class:`StoragesOperations` + * 2022-09-01-preview: :class:`StoragesOperations` + * 2022-11-01-preview: :class:`StoragesOperations` """ api_version = self._get_api_version('storages') if api_version == '2021-09-01-preview': @@ -743,8 +974,13 @@ def storages(self): from .v2022_03_01_preview.operations import StoragesOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import StoragesOperations as OperationClass + elif api_version == '2022-09-01-preview': + from .v2022_09_01_preview.operations import StoragesOperations as OperationClass + elif api_version == '2022-11-01-preview': + from .v2022_11_01_preview.operations import StoragesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'storages'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) def close(self): diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/_configuration.py index 60e24d4ade15..863d4258fff8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class AppPlatformManagementClientConfiguration(Configuration): @@ -28,16 +26,16 @@ class AppPlatformManagementClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/_serialization.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/_serialization.py new file mode 100644 index 000000000000..240df16c57f3 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# 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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/aio/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/aio/_app_platform_management_client.py index 70fafb7c0fa0..32473fbb0218 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/aio/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/aio/_app_platform_management_client.py @@ -11,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import AppPlatformManagementClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -42,9 +40,9 @@ class AppPlatformManagementClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -96,6 +94,8 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2022-03-01-preview: :mod:`v2022_03_01_preview.models` * 2022-04-01: :mod:`v2022_04_01.models` * 2022-05-01-preview: :mod:`v2022_05_01_preview.models` + * 2022-09-01-preview: :mod:`v2022_09_01_preview.models` + * 2022-11-01-preview: :mod:`v2022_11_01_preview.models` """ if api_version == '2020-07-01': from ..v2020_07_01 import models @@ -121,6 +121,12 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview import models return models + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview import models + return models + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -130,6 +136,8 @@ def api_portal_custom_domains(self): * 2022-01-01-preview: :class:`ApiPortalCustomDomainsOperations` * 2022-03-01-preview: :class:`ApiPortalCustomDomainsOperations` * 2022-05-01-preview: :class:`ApiPortalCustomDomainsOperations` + * 2022-09-01-preview: :class:`ApiPortalCustomDomainsOperations` + * 2022-11-01-preview: :class:`ApiPortalCustomDomainsOperations` """ api_version = self._get_api_version('api_portal_custom_domains') if api_version == '2022-01-01-preview': @@ -138,8 +146,13 @@ def api_portal_custom_domains(self): from ..v2022_03_01_preview.aio.operations import ApiPortalCustomDomainsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import ApiPortalCustomDomainsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import ApiPortalCustomDomainsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import ApiPortalCustomDomainsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'api_portal_custom_domains'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -149,6 +162,8 @@ def api_portals(self): * 2022-01-01-preview: :class:`ApiPortalsOperations` * 2022-03-01-preview: :class:`ApiPortalsOperations` * 2022-05-01-preview: :class:`ApiPortalsOperations` + * 2022-09-01-preview: :class:`ApiPortalsOperations` + * 2022-11-01-preview: :class:`ApiPortalsOperations` """ api_version = self._get_api_version('api_portals') if api_version == '2022-01-01-preview': @@ -157,8 +172,41 @@ def api_portals(self): from ..v2022_03_01_preview.aio.operations import ApiPortalsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import ApiPortalsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import ApiPortalsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import ApiPortalsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'api_portals'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def application_accelerators(self): + """Instance depends on the API version: + + * 2022-11-01-preview: :class:`ApplicationAcceleratorsOperations` + """ + api_version = self._get_api_version('application_accelerators') + if api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import ApplicationAcceleratorsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'application_accelerators'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def application_live_views(self): + """Instance depends on the API version: + + * 2022-11-01-preview: :class:`ApplicationLiveViewsOperations` + """ + api_version = self._get_api_version('application_live_views') + if api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import ApplicationLiveViewsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'application_live_views'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -173,6 +221,8 @@ def apps(self): * 2022-03-01-preview: :class:`AppsOperations` * 2022-04-01: :class:`AppsOperations` * 2022-05-01-preview: :class:`AppsOperations` + * 2022-09-01-preview: :class:`AppsOperations` + * 2022-11-01-preview: :class:`AppsOperations` """ api_version = self._get_api_version('apps') if api_version == '2020-07-01': @@ -191,8 +241,13 @@ def apps(self): from ..v2022_04_01.aio.operations import AppsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import AppsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import AppsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import AppsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'apps'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -207,6 +262,8 @@ def bindings(self): * 2022-03-01-preview: :class:`BindingsOperations` * 2022-04-01: :class:`BindingsOperations` * 2022-05-01-preview: :class:`BindingsOperations` + * 2022-09-01-preview: :class:`BindingsOperations` + * 2022-11-01-preview: :class:`BindingsOperations` """ api_version = self._get_api_version('bindings') if api_version == '2020-07-01': @@ -225,8 +282,13 @@ def bindings(self): from ..v2022_04_01.aio.operations import BindingsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import BindingsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import BindingsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import BindingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'bindings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -237,6 +299,8 @@ def build_service(self): * 2022-03-01-preview: :class:`BuildServiceOperations` * 2022-04-01: :class:`BuildServiceOperations` * 2022-05-01-preview: :class:`BuildServiceOperations` + * 2022-09-01-preview: :class:`BuildServiceOperations` + * 2022-11-01-preview: :class:`BuildServiceOperations` """ api_version = self._get_api_version('build_service') if api_version == '2022-01-01-preview': @@ -247,8 +311,13 @@ def build_service(self): from ..v2022_04_01.aio.operations import BuildServiceOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import BuildServiceOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import BuildServiceOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import BuildServiceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'build_service'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -259,6 +328,8 @@ def build_service_agent_pool(self): * 2022-03-01-preview: :class:`BuildServiceAgentPoolOperations` * 2022-04-01: :class:`BuildServiceAgentPoolOperations` * 2022-05-01-preview: :class:`BuildServiceAgentPoolOperations` + * 2022-09-01-preview: :class:`BuildServiceAgentPoolOperations` + * 2022-11-01-preview: :class:`BuildServiceAgentPoolOperations` """ api_version = self._get_api_version('build_service_agent_pool') if api_version == '2022-01-01-preview': @@ -269,8 +340,13 @@ def build_service_agent_pool(self): from ..v2022_04_01.aio.operations import BuildServiceAgentPoolOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import BuildServiceAgentPoolOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import BuildServiceAgentPoolOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import BuildServiceAgentPoolOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'build_service_agent_pool'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -281,6 +357,8 @@ def build_service_builder(self): * 2022-03-01-preview: :class:`BuildServiceBuilderOperations` * 2022-04-01: :class:`BuildServiceBuilderOperations` * 2022-05-01-preview: :class:`BuildServiceBuilderOperations` + * 2022-09-01-preview: :class:`BuildServiceBuilderOperations` + * 2022-11-01-preview: :class:`BuildServiceBuilderOperations` """ api_version = self._get_api_version('build_service_builder') if api_version == '2022-01-01-preview': @@ -291,8 +369,13 @@ def build_service_builder(self): from ..v2022_04_01.aio.operations import BuildServiceBuilderOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import BuildServiceBuilderOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import BuildServiceBuilderOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import BuildServiceBuilderOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'build_service_builder'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -303,6 +386,8 @@ def buildpack_binding(self): * 2022-03-01-preview: :class:`BuildpackBindingOperations` * 2022-04-01: :class:`BuildpackBindingOperations` * 2022-05-01-preview: :class:`BuildpackBindingOperations` + * 2022-09-01-preview: :class:`BuildpackBindingOperations` + * 2022-11-01-preview: :class:`BuildpackBindingOperations` """ api_version = self._get_api_version('buildpack_binding') if api_version == '2022-01-01-preview': @@ -313,8 +398,13 @@ def buildpack_binding(self): from ..v2022_04_01.aio.operations import BuildpackBindingOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import BuildpackBindingOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import BuildpackBindingOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import BuildpackBindingOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'buildpack_binding'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -329,6 +419,8 @@ def certificates(self): * 2022-03-01-preview: :class:`CertificatesOperations` * 2022-04-01: :class:`CertificatesOperations` * 2022-05-01-preview: :class:`CertificatesOperations` + * 2022-09-01-preview: :class:`CertificatesOperations` + * 2022-11-01-preview: :class:`CertificatesOperations` """ api_version = self._get_api_version('certificates') if api_version == '2020-07-01': @@ -347,8 +439,13 @@ def certificates(self): from ..v2022_04_01.aio.operations import CertificatesOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import CertificatesOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import CertificatesOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import CertificatesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'certificates'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -363,6 +460,8 @@ def config_servers(self): * 2022-03-01-preview: :class:`ConfigServersOperations` * 2022-04-01: :class:`ConfigServersOperations` * 2022-05-01-preview: :class:`ConfigServersOperations` + * 2022-09-01-preview: :class:`ConfigServersOperations` + * 2022-11-01-preview: :class:`ConfigServersOperations` """ api_version = self._get_api_version('config_servers') if api_version == '2020-07-01': @@ -381,8 +480,13 @@ def config_servers(self): from ..v2022_04_01.aio.operations import ConfigServersOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import ConfigServersOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import ConfigServersOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import ConfigServersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'config_servers'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -393,6 +497,8 @@ def configuration_services(self): * 2022-03-01-preview: :class:`ConfigurationServicesOperations` * 2022-04-01: :class:`ConfigurationServicesOperations` * 2022-05-01-preview: :class:`ConfigurationServicesOperations` + * 2022-09-01-preview: :class:`ConfigurationServicesOperations` + * 2022-11-01-preview: :class:`ConfigurationServicesOperations` """ api_version = self._get_api_version('configuration_services') if api_version == '2022-01-01-preview': @@ -403,8 +509,13 @@ def configuration_services(self): from ..v2022_04_01.aio.operations import ConfigurationServicesOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import ConfigurationServicesOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import ConfigurationServicesOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import ConfigurationServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'configuration_services'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -419,6 +530,8 @@ def custom_domains(self): * 2022-03-01-preview: :class:`CustomDomainsOperations` * 2022-04-01: :class:`CustomDomainsOperations` * 2022-05-01-preview: :class:`CustomDomainsOperations` + * 2022-09-01-preview: :class:`CustomDomainsOperations` + * 2022-11-01-preview: :class:`CustomDomainsOperations` """ api_version = self._get_api_version('custom_domains') if api_version == '2020-07-01': @@ -437,8 +550,27 @@ def custom_domains(self): from ..v2022_04_01.aio.operations import CustomDomainsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import CustomDomainsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import CustomDomainsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import CustomDomainsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'custom_domains'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def customized_accelerators(self): + """Instance depends on the API version: + + * 2022-11-01-preview: :class:`CustomizedAcceleratorsOperations` + """ + api_version = self._get_api_version('customized_accelerators') + if api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import CustomizedAcceleratorsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'customized_accelerators'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -453,6 +585,8 @@ def deployments(self): * 2022-03-01-preview: :class:`DeploymentsOperations` * 2022-04-01: :class:`DeploymentsOperations` * 2022-05-01-preview: :class:`DeploymentsOperations` + * 2022-09-01-preview: :class:`DeploymentsOperations` + * 2022-11-01-preview: :class:`DeploymentsOperations` """ api_version = self._get_api_version('deployments') if api_version == '2020-07-01': @@ -471,8 +605,27 @@ def deployments(self): from ..v2022_04_01.aio.operations import DeploymentsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import DeploymentsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import DeploymentsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import DeploymentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'deployments'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def dev_tool_portals(self): + """Instance depends on the API version: + + * 2022-11-01-preview: :class:`DevToolPortalsOperations` + """ + api_version = self._get_api_version('dev_tool_portals') + if api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import DevToolPortalsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'dev_tool_portals'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -482,6 +635,8 @@ def gateway_custom_domains(self): * 2022-01-01-preview: :class:`GatewayCustomDomainsOperations` * 2022-03-01-preview: :class:`GatewayCustomDomainsOperations` * 2022-05-01-preview: :class:`GatewayCustomDomainsOperations` + * 2022-09-01-preview: :class:`GatewayCustomDomainsOperations` + * 2022-11-01-preview: :class:`GatewayCustomDomainsOperations` """ api_version = self._get_api_version('gateway_custom_domains') if api_version == '2022-01-01-preview': @@ -490,8 +645,13 @@ def gateway_custom_domains(self): from ..v2022_03_01_preview.aio.operations import GatewayCustomDomainsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import GatewayCustomDomainsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import GatewayCustomDomainsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import GatewayCustomDomainsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'gateway_custom_domains'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -501,6 +661,8 @@ def gateway_route_configs(self): * 2022-01-01-preview: :class:`GatewayRouteConfigsOperations` * 2022-03-01-preview: :class:`GatewayRouteConfigsOperations` * 2022-05-01-preview: :class:`GatewayRouteConfigsOperations` + * 2022-09-01-preview: :class:`GatewayRouteConfigsOperations` + * 2022-11-01-preview: :class:`GatewayRouteConfigsOperations` """ api_version = self._get_api_version('gateway_route_configs') if api_version == '2022-01-01-preview': @@ -509,8 +671,13 @@ def gateway_route_configs(self): from ..v2022_03_01_preview.aio.operations import GatewayRouteConfigsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import GatewayRouteConfigsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import GatewayRouteConfigsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import GatewayRouteConfigsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'gateway_route_configs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -520,6 +687,8 @@ def gateways(self): * 2022-01-01-preview: :class:`GatewaysOperations` * 2022-03-01-preview: :class:`GatewaysOperations` * 2022-05-01-preview: :class:`GatewaysOperations` + * 2022-09-01-preview: :class:`GatewaysOperations` + * 2022-11-01-preview: :class:`GatewaysOperations` """ api_version = self._get_api_version('gateways') if api_version == '2022-01-01-preview': @@ -528,8 +697,13 @@ def gateways(self): from ..v2022_03_01_preview.aio.operations import GatewaysOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import GatewaysOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import GatewaysOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import GatewaysOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'gateways'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -544,6 +718,8 @@ def monitoring_settings(self): * 2022-03-01-preview: :class:`MonitoringSettingsOperations` * 2022-04-01: :class:`MonitoringSettingsOperations` * 2022-05-01-preview: :class:`MonitoringSettingsOperations` + * 2022-09-01-preview: :class:`MonitoringSettingsOperations` + * 2022-11-01-preview: :class:`MonitoringSettingsOperations` """ api_version = self._get_api_version('monitoring_settings') if api_version == '2020-07-01': @@ -562,8 +738,13 @@ def monitoring_settings(self): from ..v2022_04_01.aio.operations import MonitoringSettingsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import MonitoringSettingsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import MonitoringSettingsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import MonitoringSettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'monitoring_settings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -578,6 +759,8 @@ def operations(self): * 2022-03-01-preview: :class:`Operations` * 2022-04-01: :class:`Operations` * 2022-05-01-preview: :class:`Operations` + * 2022-09-01-preview: :class:`Operations` + * 2022-11-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2020-07-01': @@ -596,8 +779,27 @@ def operations(self): from ..v2022_04_01.aio.operations import Operations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import Operations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import Operations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def predefined_accelerators(self): + """Instance depends on the API version: + + * 2022-11-01-preview: :class:`PredefinedAcceleratorsOperations` + """ + api_version = self._get_api_version('predefined_accelerators') + if api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import PredefinedAcceleratorsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'predefined_accelerators'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -612,6 +814,8 @@ def runtime_versions(self): * 2022-03-01-preview: :class:`RuntimeVersionsOperations` * 2022-04-01: :class:`RuntimeVersionsOperations` * 2022-05-01-preview: :class:`RuntimeVersionsOperations` + * 2022-09-01-preview: :class:`RuntimeVersionsOperations` + * 2022-11-01-preview: :class:`RuntimeVersionsOperations` """ api_version = self._get_api_version('runtime_versions') if api_version == '2020-07-01': @@ -630,8 +834,13 @@ def runtime_versions(self): from ..v2022_04_01.aio.operations import RuntimeVersionsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import RuntimeVersionsOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import RuntimeVersionsOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import RuntimeVersionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'runtime_versions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -642,6 +851,8 @@ def service_registries(self): * 2022-03-01-preview: :class:`ServiceRegistriesOperations` * 2022-04-01: :class:`ServiceRegistriesOperations` * 2022-05-01-preview: :class:`ServiceRegistriesOperations` + * 2022-09-01-preview: :class:`ServiceRegistriesOperations` + * 2022-11-01-preview: :class:`ServiceRegistriesOperations` """ api_version = self._get_api_version('service_registries') if api_version == '2022-01-01-preview': @@ -652,8 +863,13 @@ def service_registries(self): from ..v2022_04_01.aio.operations import ServiceRegistriesOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import ServiceRegistriesOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import ServiceRegistriesOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import ServiceRegistriesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'service_registries'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -668,6 +884,8 @@ def services(self): * 2022-03-01-preview: :class:`ServicesOperations` * 2022-04-01: :class:`ServicesOperations` * 2022-05-01-preview: :class:`ServicesOperations` + * 2022-09-01-preview: :class:`ServicesOperations` + * 2022-11-01-preview: :class:`ServicesOperations` """ api_version = self._get_api_version('services') if api_version == '2020-07-01': @@ -686,8 +904,13 @@ def services(self): from ..v2022_04_01.aio.operations import ServicesOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import ServicesOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import ServicesOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import ServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'services'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -702,6 +925,8 @@ def skus(self): * 2022-03-01-preview: :class:`SkusOperations` * 2022-04-01: :class:`SkusOperations` * 2022-05-01-preview: :class:`SkusOperations` + * 2022-09-01-preview: :class:`SkusOperations` + * 2022-11-01-preview: :class:`SkusOperations` """ api_version = self._get_api_version('skus') if api_version == '2020-07-01': @@ -720,8 +945,13 @@ def skus(self): from ..v2022_04_01.aio.operations import SkusOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import SkusOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import SkusOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import SkusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'skus'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -732,6 +962,8 @@ def storages(self): * 2022-01-01-preview: :class:`StoragesOperations` * 2022-03-01-preview: :class:`StoragesOperations` * 2022-05-01-preview: :class:`StoragesOperations` + * 2022-09-01-preview: :class:`StoragesOperations` + * 2022-11-01-preview: :class:`StoragesOperations` """ api_version = self._get_api_version('storages') if api_version == '2021-09-01-preview': @@ -742,8 +974,13 @@ def storages(self): from ..v2022_03_01_preview.aio.operations import StoragesOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import StoragesOperations as OperationClass + elif api_version == '2022-09-01-preview': + from ..v2022_09_01_preview.aio.operations import StoragesOperations as OperationClass + elif api_version == '2022-11-01-preview': + from ..v2022_11_01_preview.aio.operations import StoragesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'storages'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) async def close(self): diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/aio/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/aio/_configuration.py index 10eb9d6f0e9a..3bea3139dcab 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/aio/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/aio/_configuration.py @@ -26,9 +26,9 @@ class AppPlatformManagementClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/__init__.py index 41ec6d71ff7f..a6bfaa2de14d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_app_platform_management_client.py index 6d7ae544c6a9..f53eb9588723 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_app_platform_management_client.py @@ -9,20 +9,32 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import AppPlatformManagementClientConfiguration -from .operations import AppsOperations, BindingsOperations, CertificatesOperations, ConfigServersOperations, CustomDomainsOperations, DeploymentsOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServicesOperations, SkusOperations +from .operations import ( + AppsOperations, + BindingsOperations, + CertificatesOperations, + ConfigServersOperations, + CustomDomainsOperations, + DeploymentsOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServicesOperations, + SkusOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Cloud. :ivar services: ServicesOperations operations @@ -49,10 +61,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib azure.mgmt.appplatform.v2020_07_01.operations.RuntimeVersionsOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.appplatform.v2020_07_01.operations.SkusOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -70,7 +82,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -79,22 +93,21 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -103,7 +116,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_configuration.py index d275183a2afb..02a095eb09bf 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-07-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", "2020-07-01") # type: Literal["2020-07-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_metadata.json b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_metadata.json index e256b0c34706..e4927d0b2b66 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_metadata.json +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}, \"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\": [\"AppPlatformManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -109,4 +109,4 @@ "runtime_versions": "RuntimeVersionsOperations", "skus": "SkusOperations" } -} \ No newline at end of file +} diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_vendor.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_vendor.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_version.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_version.py index e7ffc58c0429..92453d8691d9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_version.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.1.0" +VERSION = "6.1.0" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/__init__.py index 44ce4a5043f8..398c48287ad8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._app_platform_management_client import AppPlatformManagementClient -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/_app_platform_management_client.py index a183031693f3..703bf5642221 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/_app_platform_management_client.py @@ -9,20 +9,32 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import AppPlatformManagementClientConfiguration -from .operations import AppsOperations, BindingsOperations, CertificatesOperations, ConfigServersOperations, CustomDomainsOperations, DeploymentsOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServicesOperations, SkusOperations +from .operations import ( + AppsOperations, + BindingsOperations, + CertificatesOperations, + ConfigServersOperations, + CustomDomainsOperations, + DeploymentsOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServicesOperations, + SkusOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Cloud. :ivar services: ServicesOperations operations @@ -51,10 +63,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib azure.mgmt.appplatform.v2020_07_01.aio.operations.RuntimeVersionsOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.appplatform.v2020_07_01.aio.operations.SkusOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -72,7 +84,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -81,22 +95,21 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -105,7 +118,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/_configuration.py index fe974e61f1b2..6127849b2ed6 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-07-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", "2020-07-01") # type: Literal["2020-07-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/__init__.py index aa6fe5cd0cfc..a3674f282ddb 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/__init__.py @@ -18,16 +18,22 @@ from ._runtime_versions_operations import RuntimeVersionsOperations from ._skus_operations import SkusOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', + "ServicesOperations", + "ConfigServersOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_apps_operations.py index c8185f126f41..aebf807a28be 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_apps_operations.py @@ -6,46 +6,67 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._apps_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_get_resource_upload_url_request, build_list_request, build_update_request_initial, build_validate_domain_request -T = TypeVar('T') +from ...operations._apps_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_get_resource_upload_url_request, + build_list_request, + build_update_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AppsOperations: - """AppsOperations 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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.aio.AppPlatformManagementClient`'s + :attr:`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_async async def get( @@ -55,102 +76,121 @@ async def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(app_resource, 'AppResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - 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(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -158,21 +198,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_07_01.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,20 +299,24 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2020_07_01.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_07_01.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -206,84 +329,92 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.AppResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -293,25 +424,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -323,83 +449,104 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(app_resource, 'AppResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -407,18 +554,97 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_07_01.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -426,20 +652,24 @@ async def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2020_07_01.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_07_01.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -452,104 +682,117 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.AppResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncIterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AppResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -563,10 +806,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 @@ -576,74 +817,135 @@ 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.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace_async async def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def validate_domain( @@ -651,66 +953,84 @@ async def validate_domain( resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: Union[_models.CustomDomainValidatePayload, IO], **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. :type validate_payload: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainValidatePayload + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_bindings_operations.py index a5ad80d960f1..c54af3522934 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_bindings_operations.py @@ -6,113 +6,132 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._bindings_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._bindings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BindingsOperations: - """BindingsOperations 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 BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.aio.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +139,53 @@ async def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(binding_resource, 'BindingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - 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(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -160,21 +193,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +301,26 @@ async def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +333,19 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.BindingResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +353,74 @@ async def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -301,28 +430,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -334,46 +457,53 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _update_initial( self, @@ -381,39 +511,53 @@ async def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(binding_resource, 'BindingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -421,18 +565,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +670,26 @@ async def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +702,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.BindingResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +722,103 @@ async def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +832,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 @@ -599,8 +843,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_certificates_operations.py index 6f03d9552ddf..6f4bc87ecc83 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_certificates_operations.py @@ -6,147 +6,180 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class 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.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.aio.AppPlatformManagementClient`'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_async async def get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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_resource, 'CertificateResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - 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(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -154,21 +187,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -176,20 +288,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CertificateResource"]: + ) -> AsyncLROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. - :type certificate_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type certificate_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -202,84 +319,92 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.CertificateResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -289,25 +414,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -319,98 +439,114 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -424,10 +560,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 @@ -437,8 +571,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_config_servers_operations.py index 88c5815fdada..6aad79f14d9a 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_config_servers_operations.py @@ -6,139 +6,170 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._config_servers_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial, build_validate_request_initial -T = TypeVar('T') +from ...operations._config_servers_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConfigServersOperations: - """ConfigServersOperations 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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.aio.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(config_server_resource, 'ConfigServerResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,36 +177,114 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -188,86 +297,106 @@ async def begin_update_put( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.ConfigServerResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(config_server_resource, 'ConfigServerResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -275,36 +404,114 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -317,86 +524,106 @@ async def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.ConfigServerResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(config_server_settings, 'ConfigServerSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -404,36 +631,114 @@ async def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerSettings + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -446,47 +751,52 @@ async def begin_validate( or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.ConfigServerSettingsValidateResult"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = await self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_custom_domains_operations.py index 4a0375028662..ee92e5af065c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_custom_domains_operations.py @@ -6,113 +6,132 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._custom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CustomDomainsOperations: - """CustomDomainsOperations 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 CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.aio.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +139,53 @@ async def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(domain_resource, 'CustomDomainResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - 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(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -160,21 +193,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +301,26 @@ async def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. - :type domain_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +333,19 @@ async def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.CustomDomainResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +353,74 @@ async def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -301,28 +430,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -334,46 +457,53 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _update_initial( self, @@ -381,39 +511,53 @@ async def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(domain_resource, 'CustomDomainResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -421,18 +565,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +670,26 @@ async def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. - :type domain_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +702,19 @@ async def begin_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.CustomDomainResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +722,104 @@ async def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +833,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 @@ -599,8 +844,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_deployments_operations.py index 988d0302576b..070d0b699f45 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_deployments_operations.py @@ -6,113 +6,137 @@ # Code generated 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, List, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._deployments_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_log_file_url_request, build_get_request, build_list_for_cluster_request, build_list_request, build_restart_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._deployments_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_log_file_url_request, + build_get_request, + build_list_for_cluster_request, + build_list_request, + build_restart_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeploymentsOperations: - """DeploymentsOperations 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 DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.aio.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +144,53 @@ async def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(deployment_resource, 'DeploymentResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - 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(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -160,21 +198,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +306,26 @@ async def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. - :type deployment_resource: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +338,19 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.DeploymentResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +358,74 @@ async def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -301,28 +435,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -334,46 +462,53 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _update_initial( self, @@ -381,39 +516,53 @@ async def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(deployment_resource, 'DeploymentResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -421,18 +570,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +675,26 @@ async def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. - :type deployment_resource: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +707,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.DeploymentResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -489,32 +727,38 @@ async def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -524,60 +768,70 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + ) -> AsyncIterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -591,10 +845,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 @@ -604,69 +856,74 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -680,10 +937,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 @@ -693,46 +948,45 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -742,28 +996,22 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -775,81 +1023,89 @@ async def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -859,28 +1115,22 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -892,81 +1142,89 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore async def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -976,28 +1234,22 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async - async def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1009,98 +1261,106 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async async def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1109,12 +1369,11 @@ async def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_monitoring_settings_operations.py index 61082351ede3..94b1410264c2 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_monitoring_settings_operations.py @@ -6,139 +6,171 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._monitoring_settings_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial -T = TypeVar('T') +from ...operations._monitoring_settings_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MonitoringSettingsOperations: - """MonitoringSettingsOperations 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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.aio.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(monitoring_setting_resource, 'MonitoringSettingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,37 +178,115 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,86 +299,106 @@ async def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.MonitoringSettingResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(monitoring_setting_resource, 'MonitoringSettingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -276,37 +406,115 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -319,47 +527,53 @@ async def begin_update_patch( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.MonitoringSettingResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_operations.py index ab4aa3d1ff90..f54787b1f6a9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_operations.py @@ -6,82 +6,108 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.aio.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.appplatform.v2020_07_01.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,10 +121,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 @@ -108,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_runtime_versions_operations.py index c2ea04af068a..e9994c4ff4f3 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_runtime_versions_operations.py @@ -6,88 +6,102 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import 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._runtime_versions_operations import build_list_runtime_versions_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RuntimeVersionsOperations: - """RuntimeVersionsOperations 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 RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.aio.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + async def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_services_operations.py index ea48483c3ada..d63325331a1f 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_services_operations.py @@ -6,141 +6,176 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._services_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_disable_test_endpoint_request, build_enable_test_endpoint_request, build_get_request, build_list_by_subscription_request, build_list_request, build_list_test_keys_request, build_regenerate_test_key_request, build_update_request_initial -T = TypeVar('T') +from ...operations._services_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_disable_test_endpoint_request, + build_enable_test_endpoint_request, + build_get_request, + build_list_by_subscription_request, + build_list_request, + build_list_test_keys_request, + build_regenerate_test_key_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ServicesOperations: - """ServicesOperations 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 ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.aio.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(resource, 'ServiceResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - 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(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -148,39 +183,43 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -193,81 +232,159 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] + :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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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 [202, 204]: @@ -277,22 +394,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -304,80 +415,97 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(resource, 'ServiceResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -385,36 +513,40 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -427,220 +559,372 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] + :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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + async def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2020_07_01.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2020_07_01.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2020_07_01.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace_async async def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -650,170 +934,241 @@ async def disable_test_endpoint( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace_async async def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - - @distributed_trace_async + @overload async def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2020_07_01.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2020_07_01.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(availability_parameters, 'NameAvailabilityParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -827,10 +1182,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 @@ -840,58 +1193,66 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -905,10 +1266,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 @@ -918,8 +1277,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_skus_operations.py index e105e3486111..8c9ded5254e1 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/aio/operations/_skus_operations.py @@ -6,85 +6,109 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SkusOperations: - """SkusOperations 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 SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.aio.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) + :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -98,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -111,8 +133,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/__init__.py index e4dbda7bd1b2..f3e39fb7a34b 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/__init__.py @@ -75,111 +75,113 @@ from ._models_py3 import TrackedResource from ._models_py3 import UserSourceInfo - -from ._app_platform_management_client_enums import ( - ActionType, - AppResourceProvisioningState, - ConfigServerState, - DeploymentResourceProvisioningState, - DeploymentResourceStatus, - ManagedIdentityType, - MonitoringSettingState, - ProvisioningState, - ResourceSkuRestrictionsReasonCode, - ResourceSkuRestrictionsType, - RuntimeVersion, - SkuScaleType, - SupportedRuntimePlatform, - SupportedRuntimeValue, - TestKeyType, - TrafficDirection, - UserSourceType, -) +from ._app_platform_management_client_enums import ActionType +from ._app_platform_management_client_enums import AppResourceProvisioningState +from ._app_platform_management_client_enums import ConfigServerState +from ._app_platform_management_client_enums import DeploymentResourceProvisioningState +from ._app_platform_management_client_enums import DeploymentResourceStatus +from ._app_platform_management_client_enums import ManagedIdentityType +from ._app_platform_management_client_enums import MonitoringSettingState +from ._app_platform_management_client_enums import ProvisioningState +from ._app_platform_management_client_enums import ResourceSkuRestrictionsReasonCode +from ._app_platform_management_client_enums import ResourceSkuRestrictionsType +from ._app_platform_management_client_enums import RuntimeVersion +from ._app_platform_management_client_enums import SkuScaleType +from ._app_platform_management_client_enums import SupportedRuntimePlatform +from ._app_platform_management_client_enums import SupportedRuntimeValue +from ._app_platform_management_client_enums import TestKeyType +from ._app_platform_management_client_enums import TrafficDirection +from ._app_platform_management_client_enums import UserSourceType +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__ = [ - 'AppResource', - 'AppResourceCollection', - 'AppResourceProperties', - 'AvailableOperations', - 'AvailableRuntimeVersions', - 'BindingResource', - 'BindingResourceCollection', - 'BindingResourceProperties', - 'CertificateProperties', - 'CertificateResource', - 'CertificateResourceCollection', - 'CloudErrorBody', - 'ClusterResourceProperties', - 'ConfigServerGitProperty', - 'ConfigServerProperties', - 'ConfigServerResource', - 'ConfigServerSettings', - 'ConfigServerSettingsErrorRecord', - 'ConfigServerSettingsValidateResult', - 'CustomDomainProperties', - 'CustomDomainResource', - 'CustomDomainResourceCollection', - 'CustomDomainValidatePayload', - 'CustomDomainValidateResult', - 'DeploymentInstance', - 'DeploymentResource', - 'DeploymentResourceCollection', - 'DeploymentResourceProperties', - 'DeploymentSettings', - 'Error', - 'GitPatternRepository', - 'LogFileUrlResponse', - 'LogSpecification', - 'ManagedIdentityProperties', - 'MetricDimension', - 'MetricSpecification', - 'MonitoringSettingProperties', - 'MonitoringSettingResource', - 'NameAvailability', - 'NameAvailabilityParameters', - 'NetworkProfile', - 'NetworkProfileOutboundIPs', - 'OperationDetail', - 'OperationDisplay', - 'OperationProperties', - 'PersistentDisk', - 'ProxyResource', - 'RegenerateTestKeyRequestPayload', - 'RequiredTraffic', - 'Resource', - 'ResourceSku', - 'ResourceSkuCapabilities', - 'ResourceSkuCollection', - 'ResourceSkuLocationInfo', - 'ResourceSkuRestrictionInfo', - 'ResourceSkuRestrictions', - 'ResourceSkuZoneDetails', - 'ResourceUploadDefinition', - 'ServiceResource', - 'ServiceResourceList', - 'ServiceSpecification', - 'Sku', - 'SkuCapacity', - 'SupportedRuntimeVersion', - 'TemporaryDisk', - 'TestKeys', - 'TrackedResource', - 'UserSourceInfo', - 'ActionType', - 'AppResourceProvisioningState', - 'ConfigServerState', - 'DeploymentResourceProvisioningState', - 'DeploymentResourceStatus', - 'ManagedIdentityType', - 'MonitoringSettingState', - 'ProvisioningState', - 'ResourceSkuRestrictionsReasonCode', - 'ResourceSkuRestrictionsType', - 'RuntimeVersion', - 'SkuScaleType', - 'SupportedRuntimePlatform', - 'SupportedRuntimeValue', - 'TestKeyType', - 'TrafficDirection', - 'UserSourceType', + "AppResource", + "AppResourceCollection", + "AppResourceProperties", + "AvailableOperations", + "AvailableRuntimeVersions", + "BindingResource", + "BindingResourceCollection", + "BindingResourceProperties", + "CertificateProperties", + "CertificateResource", + "CertificateResourceCollection", + "CloudErrorBody", + "ClusterResourceProperties", + "ConfigServerGitProperty", + "ConfigServerProperties", + "ConfigServerResource", + "ConfigServerSettings", + "ConfigServerSettingsErrorRecord", + "ConfigServerSettingsValidateResult", + "CustomDomainProperties", + "CustomDomainResource", + "CustomDomainResourceCollection", + "CustomDomainValidatePayload", + "CustomDomainValidateResult", + "DeploymentInstance", + "DeploymentResource", + "DeploymentResourceCollection", + "DeploymentResourceProperties", + "DeploymentSettings", + "Error", + "GitPatternRepository", + "LogFileUrlResponse", + "LogSpecification", + "ManagedIdentityProperties", + "MetricDimension", + "MetricSpecification", + "MonitoringSettingProperties", + "MonitoringSettingResource", + "NameAvailability", + "NameAvailabilityParameters", + "NetworkProfile", + "NetworkProfileOutboundIPs", + "OperationDetail", + "OperationDisplay", + "OperationProperties", + "PersistentDisk", + "ProxyResource", + "RegenerateTestKeyRequestPayload", + "RequiredTraffic", + "Resource", + "ResourceSku", + "ResourceSkuCapabilities", + "ResourceSkuCollection", + "ResourceSkuLocationInfo", + "ResourceSkuRestrictionInfo", + "ResourceSkuRestrictions", + "ResourceSkuZoneDetails", + "ResourceUploadDefinition", + "ServiceResource", + "ServiceResourceList", + "ServiceSpecification", + "Sku", + "SkuCapacity", + "SupportedRuntimeVersion", + "TemporaryDisk", + "TestKeys", + "TrackedResource", + "UserSourceInfo", + "ActionType", + "AppResourceProvisioningState", + "ConfigServerState", + "DeploymentResourceProvisioningState", + "DeploymentResourceStatus", + "ManagedIdentityType", + "MonitoringSettingState", + "ProvisioningState", + "ResourceSkuRestrictionsReasonCode", + "ResourceSkuRestrictionsType", + "RuntimeVersion", + "SkuScaleType", + "SupportedRuntimePlatform", + "SupportedRuntimeValue", + "TestKeyType", + "TrafficDirection", + "UserSourceType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/_app_platform_management_client_enums.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/_app_platform_management_client_enums.py index 483260921151..878e2ebf3d42 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/_app_platform_management_client_enums.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/_app_platform_management_client_enums.py @@ -7,28 +7,26 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - """ +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" INTERNAL = "Internal" -class AppResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the App - """ + +class AppResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the App.""" SUCCEEDED = "Succeeded" FAILED = "Failed" CREATING = "Creating" UPDATING = "Updating" -class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the config server. - """ + +class ConfigServerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the config server.""" NOT_AVAILABLE = "NotAvailable" DELETED = "Deleted" @@ -36,18 +34,18 @@ class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class DeploymentResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Deployment - """ + +class DeploymentResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Deployment.""" CREATING = "Creating" UPDATING = "Updating" SUCCEEDED = "Succeeded" FAILED = "Failed" -class DeploymentResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of the Deployment - """ + +class DeploymentResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the Deployment.""" UNKNOWN = "Unknown" STOPPED = "Stopped" @@ -57,27 +55,27 @@ class DeploymentResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum UPGRADING = "Upgrading" COMPILING = "Compiling" -class ManagedIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the managed identity - """ + +class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the managed identity.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class MonitoringSettingState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Monitoring Setting. - """ + +class MonitoringSettingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Monitoring Setting.""" NOT_AVAILABLE = "NotAvailable" FAILED = "Failed" SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Service - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Service.""" CREATING = "Creating" UPDATING = "Updating" @@ -89,69 +87,70 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MOVED = "Moved" MOVE_FAILED = "MoveFailed" -class ResourceSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription' + 'NotAvailableForSubscription'. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ResourceSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets the type of restrictions. Possible values include: 'Location', 'Zone' - """ + +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the type of restrictions. Possible values include: 'Location', 'Zone'.""" LOCATION = "Location" ZONE = "Zone" -class RuntimeVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Runtime version - """ + +class RuntimeVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Runtime version.""" JAVA8 = "Java_8" JAVA11 = "Java_11" NET_CORE31 = "NetCore_31" -class SkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets or sets the type of the scale. - """ + +class SkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type of the scale.""" NONE = "None" MANUAL = "Manual" AUTOMATIC = "Automatic" -class SupportedRuntimePlatform(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The platform of this runtime version (possible values: "Java" or ".NET"). - """ + +class SupportedRuntimePlatform(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The platform of this runtime version (possible values: "Java" or ".NET").""" JAVA = "Java" _NET_CORE = ".NET Core" -class SupportedRuntimeValue(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The raw value which could be passed to deployment CRUD operations. - """ + +class SupportedRuntimeValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The raw value which could be passed to deployment CRUD operations.""" JAVA8 = "Java_8" JAVA11 = "Java_11" NET_CORE31 = "NetCore_31" -class TestKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the test key - """ + +class TestKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the test key.""" PRIMARY = "Primary" SECONDARY = "Secondary" -class TrafficDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The direction of required traffic - """ + +class TrafficDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The direction of required traffic.""" INBOUND = "Inbound" OUTBOUND = "Outbound" -class UserSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the source uploaded - """ + +class UserSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the source uploaded.""" JAR = "Jar" NET_CORE_ZIP = "NetCoreZip" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/_models_py3.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/_models_py3.py index 011dec21acc0..803c084e22da 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/_models_py3.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._app_platform_management_client_enums import * +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Resource(msrest.serialization.Model): + +class Resource(_serialization.Model): """The core properties of ARM resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -27,24 +37,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -64,24 +70,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class AppResource(ProxyResource): @@ -104,25 +106,25 @@ class AppResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'AppResourceProperties'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentityProperties'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "AppResourceProperties"}, + "identity": {"key": "identity", "type": "ManagedIdentityProperties"}, + "location": {"key": "location", "type": "str"}, } def __init__( self, *, - properties: Optional["AppResourceProperties"] = None, - identity: Optional["ManagedIdentityProperties"] = None, + properties: Optional["_models.AppResourceProperties"] = None, + identity: Optional["_models.ManagedIdentityProperties"] = None, location: Optional[str] = None, **kwargs ): @@ -135,13 +137,13 @@ def __init__( resource. :paramtype location: str """ - super(AppResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.identity = identity self.location = location -class AppResourceCollection(msrest.serialization.Model): +class AppResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of App resources. @@ -152,16 +154,12 @@ class AppResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AppResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AppResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["AppResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.AppResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of App resources. @@ -170,12 +168,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(AppResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class AppResourceProperties(msrest.serialization.Model): +class AppResourceProperties(_serialization.Model): """App resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -184,8 +182,8 @@ class AppResourceProperties(msrest.serialization.Model): :vartype public: bool :ivar url: URL of the App. :vartype url: str - :ivar provisioning_state: Provisioning state of the App. Possible values include: "Succeeded", - "Failed", "Creating", "Updating". + :ivar provisioning_state: Provisioning state of the App. Known values are: "Succeeded", + "Failed", "Creating", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2020_07_01.models.AppResourceProvisioningState :ivar active_deployment_name: Name of the active deployment of the App. @@ -203,21 +201,21 @@ class AppResourceProperties(msrest.serialization.Model): """ _validation = { - 'url': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'created_time': {'readonly': True}, + "url": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "created_time": {"readonly": True}, } _attribute_map = { - 'public': {'key': 'public', 'type': 'bool'}, - 'url': {'key': 'url', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'active_deployment_name': {'key': 'activeDeploymentName', 'type': 'str'}, - 'fqdn': {'key': 'fqdn', 'type': 'str'}, - 'https_only': {'key': 'httpsOnly', 'type': 'bool'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'temporary_disk': {'key': 'temporaryDisk', 'type': 'TemporaryDisk'}, - 'persistent_disk': {'key': 'persistentDisk', 'type': 'PersistentDisk'}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "active_deployment_name": {"key": "activeDeploymentName", "type": "str"}, + "fqdn": {"key": "fqdn", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "temporary_disk": {"key": "temporaryDisk", "type": "TemporaryDisk"}, + "persistent_disk": {"key": "persistentDisk", "type": "PersistentDisk"}, } def __init__( @@ -226,9 +224,9 @@ def __init__( public: Optional[bool] = None, active_deployment_name: Optional[str] = None, fqdn: Optional[str] = None, - https_only: Optional[bool] = False, - temporary_disk: Optional["TemporaryDisk"] = None, - persistent_disk: Optional["PersistentDisk"] = None, + https_only: bool = False, + temporary_disk: Optional["_models.TemporaryDisk"] = None, + persistent_disk: Optional["_models.PersistentDisk"] = None, **kwargs ): """ @@ -245,7 +243,7 @@ def __init__( :keyword persistent_disk: Persistent disk settings. :paramtype persistent_disk: ~azure.mgmt.appplatform.v2020_07_01.models.PersistentDisk """ - super(AppResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.public = public self.url = None self.provisioning_state = None @@ -257,7 +255,7 @@ def __init__( self.persistent_disk = persistent_disk -class AvailableOperations(msrest.serialization.Model): +class AvailableOperations(_serialization.Model): """Available operations of the service. :ivar value: Collection of available operation details. @@ -268,16 +266,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. @@ -286,12 +280,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 AvailableRuntimeVersions(msrest.serialization.Model): +class AvailableRuntimeVersions(_serialization.Model): """AvailableRuntimeVersions. Variables are only populated by the server, and will be ignored when sending a request. @@ -301,20 +295,16 @@ class AvailableRuntimeVersions(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedRuntimeVersion]'}, + "value": {"key": "value", "type": "[SupportedRuntimeVersion]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AvailableRuntimeVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -334,33 +324,28 @@ class BindingResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'BindingResourceProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "BindingResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["BindingResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BindingResourceProperties"] = None, **kwargs): """ :keyword properties: Properties of the Binding resource. :paramtype properties: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResourceProperties """ - super(BindingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BindingResourceCollection(msrest.serialization.Model): +class BindingResourceCollection(_serialization.Model): """Object that includes an array of Binding resources and a possible link for next set. :ivar value: Collection of Binding resources. @@ -371,16 +356,12 @@ class BindingResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BindingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BindingResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BindingResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Binding resources. @@ -389,12 +370,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BindingResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BindingResourceProperties(msrest.serialization.Model): +class BindingResourceProperties(_serialization.Model): """Binding resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -408,7 +389,7 @@ class BindingResourceProperties(msrest.serialization.Model): :ivar key: The key of the bound resource. :vartype key: str :ivar binding_parameters: Binding parameters of the Binding resource. - :vartype binding_parameters: dict[str, any] + :vartype binding_parameters: dict[str, JSON] :ivar generated_properties: The generated Spring Boot property file for this binding. The secret will be deducted. :vartype generated_properties: str @@ -419,22 +400,22 @@ class BindingResourceProperties(msrest.serialization.Model): """ _validation = { - 'resource_name': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'generated_properties': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, + "resource_name": {"readonly": True}, + "resource_type": {"readonly": True}, + "generated_properties": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, } _attribute_map = { - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'binding_parameters': {'key': 'bindingParameters', 'type': '{object}'}, - 'generated_properties': {'key': 'generatedProperties', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'str'}, - 'updated_at': {'key': 'updatedAt', 'type': 'str'}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "binding_parameters": {"key": "bindingParameters", "type": "{object}"}, + "generated_properties": {"key": "generatedProperties", "type": "str"}, + "created_at": {"key": "createdAt", "type": "str"}, + "updated_at": {"key": "updatedAt", "type": "str"}, } def __init__( @@ -442,7 +423,7 @@ def __init__( *, resource_id: Optional[str] = None, key: Optional[str] = None, - binding_parameters: Optional[Dict[str, Any]] = None, + binding_parameters: Optional[Dict[str, JSON]] = None, **kwargs ): """ @@ -451,9 +432,9 @@ def __init__( :keyword key: The key of the bound resource. :paramtype key: str :keyword binding_parameters: Binding parameters of the Binding resource. - :paramtype binding_parameters: dict[str, any] + :paramtype binding_parameters: dict[str, JSON] """ - super(BindingResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_name = None self.resource_type = None self.resource_id = resource_id @@ -464,7 +445,7 @@ def __init__( self.updated_at = None -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """Certificate resource payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -473,9 +454,9 @@ class CertificateProperties(msrest.serialization.Model): :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str - :ivar vault_uri: Required. The vault uri of user key vault. + :ivar vault_uri: The vault uri of user key vault. Required. :vartype vault_uri: str - :ivar key_vault_cert_name: Required. The certificate name of key vault. + :ivar key_vault_cert_name: The certificate name of key vault. Required. :vartype key_vault_cert_name: str :ivar cert_version: The certificate version of key vault. :vartype cert_version: str @@ -494,47 +475,40 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'thumbprint': {'readonly': True}, - 'vault_uri': {'required': True}, - 'key_vault_cert_name': {'required': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, - } - - _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'vault_uri': {'key': 'vaultUri', 'type': 'str'}, - 'key_vault_cert_name': {'key': 'keyVaultCertName', 'type': 'str'}, - 'cert_version': {'key': 'certVersion', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, + "thumbprint": {"readonly": True}, + "vault_uri": {"required": True}, + "key_vault_cert_name": {"required": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, } - def __init__( - self, - *, - vault_uri: str, - key_vault_cert_name: str, - cert_version: Optional[str] = None, - **kwargs - ): + _attribute_map = { + "thumbprint": {"key": "thumbprint", "type": "str"}, + "vault_uri": {"key": "vaultUri", "type": "str"}, + "key_vault_cert_name": {"key": "keyVaultCertName", "type": "str"}, + "cert_version": {"key": "certVersion", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + } + + def __init__(self, *, vault_uri: str, key_vault_cert_name: str, cert_version: Optional[str] = None, **kwargs): """ - :keyword vault_uri: Required. The vault uri of user key vault. + :keyword vault_uri: The vault uri of user key vault. Required. :paramtype vault_uri: str - :keyword key_vault_cert_name: Required. The certificate name of key vault. + :keyword key_vault_cert_name: The certificate name of key vault. Required. :paramtype key_vault_cert_name: str :keyword cert_version: The certificate version of key vault. :paramtype cert_version: str """ - super(CertificateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = None self.vault_uri = vault_uri self.key_vault_cert_name = key_vault_cert_name @@ -563,33 +537,28 @@ class CertificateResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "CertificateProperties"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: Properties of the certificate resource payload. :paramtype properties: ~azure.mgmt.appplatform.v2020_07_01.models.CertificateProperties """ - super(CertificateResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CertificateResourceCollection(msrest.serialization.Model): +class CertificateResourceCollection(_serialization.Model): """Collection compose of certificate resources list and a possible link for next page. :ivar value: The certificate resources list. @@ -599,16 +568,12 @@ class CertificateResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CertificateResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CertificateResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CertificateResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The certificate resources list. @@ -616,12 +581,12 @@ def __init__( :keyword next_link: The link to next page of certificate list. :paramtype next_link: str """ - super(CertificateResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -638,10 +603,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -650,7 +615,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -666,21 +631,20 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.appplatform.v2020_07_01.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class ClusterResourceProperties(msrest.serialization.Model): +class ClusterResourceProperties(_serialization.Model): """Service properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Provisioning state of the Service. Possible values include: - "Creating", "Updating", "Deleting", "Deleted", "Succeeded", "Failed", "Moving", "Moved", - "MoveFailed". + :ivar provisioning_state: Provisioning state of the Service. Known values are: "Creating", + "Updating", "Deleting", "Deleted", "Succeeded", "Failed", "Moving", "Moved", and "MoveFailed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2020_07_01.models.ProvisioningState :ivar network_profile: Network profile of the Service. @@ -692,43 +656,38 @@ class ClusterResourceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'version': {'readonly': True}, - 'service_id': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "service_id": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'network_profile': {'key': 'networkProfile', 'type': 'NetworkProfile'}, - 'version': {'key': 'version', 'type': 'int'}, - 'service_id': {'key': 'serviceId', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "network_profile": {"key": "networkProfile", "type": "NetworkProfile"}, + "version": {"key": "version", "type": "int"}, + "service_id": {"key": "serviceId", "type": "str"}, } - def __init__( - self, - *, - network_profile: Optional["NetworkProfile"] = None, - **kwargs - ): + def __init__(self, *, network_profile: Optional["_models.NetworkProfile"] = None, **kwargs): """ :keyword network_profile: Network profile of the Service. :paramtype network_profile: ~azure.mgmt.appplatform.v2020_07_01.models.NetworkProfile """ - super(ClusterResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.network_profile = network_profile self.version = None self.service_id = None -class ConfigServerGitProperty(msrest.serialization.Model): +class ConfigServerGitProperty(_serialization.Model): """Property of git. All required parameters must be populated in order to send to Azure. :ivar repositories: Repositories of git. :vartype repositories: list[~azure.mgmt.appplatform.v2020_07_01.models.GitPatternRepository] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -749,27 +708,27 @@ class ConfigServerGitProperty(msrest.serialization.Model): """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'repositories': {'key': 'repositories', 'type': '[GitPatternRepository]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "repositories": {"key": "repositories", "type": "[GitPatternRepository]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( self, *, uri: str, - repositories: Optional[List["GitPatternRepository"]] = None, + repositories: Optional[List["_models.GitPatternRepository"]] = None, label: Optional[str] = None, search_paths: Optional[List[str]] = None, username: Optional[str] = None, @@ -783,7 +742,7 @@ def __init__( """ :keyword repositories: Repositories of git. :paramtype repositories: list[~azure.mgmt.appplatform.v2020_07_01.models.GitPatternRepository] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -802,7 +761,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(ConfigServerGitProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.repositories = repositories self.uri = uri self.label = label @@ -815,13 +774,13 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ConfigServerProperties(msrest.serialization.Model): +class ConfigServerProperties(_serialization.Model): """Config server git properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the config server. Possible values include: "NotAvailable", - "Deleted", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the config server. Known values are: "NotAvailable", + "Deleted", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerState :ivar error: Error when apply config server settings. @@ -831,20 +790,20 @@ class ConfigServerProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'config_server': {'key': 'configServer', 'type': 'ConfigServerSettings'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "config_server": {"key": "configServer", "type": "ConfigServerSettings"}, } def __init__( self, *, - error: Optional["Error"] = None, - config_server: Optional["ConfigServerSettings"] = None, + error: Optional["_models.Error"] = None, + config_server: Optional["_models.ConfigServerSettings"] = None, **kwargs ): """ @@ -853,7 +812,7 @@ def __init__( :keyword config_server: Settings of config server. :paramtype config_server: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerSettings """ - super(ConfigServerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.config_server = config_server @@ -875,33 +834,28 @@ class ConfigServerResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ConfigServerProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ConfigServerProperties"}, } - def __init__( - self, - *, - properties: Optional["ConfigServerProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ConfigServerProperties"] = None, **kwargs): """ :keyword properties: Properties of the Config Server resource. :paramtype properties: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerProperties """ - super(ConfigServerResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ConfigServerSettings(msrest.serialization.Model): +class ConfigServerSettings(_serialization.Model): """The settings of config server. :ivar git_property: Property of git environment. @@ -909,24 +863,19 @@ class ConfigServerSettings(msrest.serialization.Model): """ _attribute_map = { - 'git_property': {'key': 'gitProperty', 'type': 'ConfigServerGitProperty'}, + "git_property": {"key": "gitProperty", "type": "ConfigServerGitProperty"}, } - def __init__( - self, - *, - git_property: Optional["ConfigServerGitProperty"] = None, - **kwargs - ): + def __init__(self, *, git_property: Optional["_models.ConfigServerGitProperty"] = None, **kwargs): """ :keyword git_property: Property of git environment. :paramtype git_property: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerGitProperty """ - super(ConfigServerSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property = git_property -class ConfigServerSettingsErrorRecord(msrest.serialization.Model): +class ConfigServerSettingsErrorRecord(_serialization.Model): """Error record of the config server settings. :ivar name: The name of the config server settings error record. @@ -938,18 +887,13 @@ class ConfigServerSettingsErrorRecord(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'messages': {'key': 'messages', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, } def __init__( - self, - *, - name: Optional[str] = None, - uri: Optional[str] = None, - messages: Optional[List[str]] = None, - **kwargs + self, *, name: Optional[str] = None, uri: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs ): """ :keyword name: The name of the config server settings error record. @@ -959,13 +903,13 @@ def __init__( :keyword messages: The detail error messages of the record. :paramtype messages: list[str] """ - super(ConfigServerSettingsErrorRecord, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.uri = uri self.messages = messages -class ConfigServerSettingsValidateResult(msrest.serialization.Model): +class ConfigServerSettingsValidateResult(_serialization.Model): """Validation result for config server settings. :ivar is_valid: Indicate if the config server settings are valid. @@ -976,15 +920,15 @@ class ConfigServerSettingsValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'details': {'key': 'details', 'type': '[ConfigServerSettingsErrorRecord]'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "details": {"key": "details", "type": "[ConfigServerSettingsErrorRecord]"}, } def __init__( self, *, is_valid: Optional[bool] = None, - details: Optional[List["ConfigServerSettingsErrorRecord"]] = None, + details: Optional[List["_models.ConfigServerSettingsErrorRecord"]] = None, **kwargs ): """ @@ -994,12 +938,12 @@ def __init__( :paramtype details: list[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerSettingsErrorRecord] """ - super(ConfigServerSettingsValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.details = details -class CustomDomainProperties(msrest.serialization.Model): +class CustomDomainProperties(_serialization.Model): """Custom domain of app resource payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1013,29 +957,23 @@ class CustomDomainProperties(msrest.serialization.Model): """ _validation = { - 'app_name': {'readonly': True}, + "app_name": {"readonly": True}, } _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'app_name': {'key': 'appName', 'type': 'str'}, - 'cert_name': {'key': 'certName', 'type': 'str'}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "app_name": {"key": "appName", "type": "str"}, + "cert_name": {"key": "certName", "type": "str"}, } - def __init__( - self, - *, - thumbprint: Optional[str] = None, - cert_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, thumbprint: Optional[str] = None, cert_name: Optional[str] = None, **kwargs): """ :keyword thumbprint: The thumbprint of bound certificate. :paramtype thumbprint: str :keyword cert_name: The bound certificate name of domain. :paramtype cert_name: str """ - super(CustomDomainProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = thumbprint self.app_name = None self.cert_name = cert_name @@ -1057,33 +995,28 @@ class CustomDomainResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'CustomDomainProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "CustomDomainProperties"}, } - def __init__( - self, - *, - properties: Optional["CustomDomainProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CustomDomainProperties"] = None, **kwargs): """ :keyword properties: Properties of the custom domain resource. :paramtype properties: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainProperties """ - super(CustomDomainResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CustomDomainResourceCollection(msrest.serialization.Model): +class CustomDomainResourceCollection(_serialization.Model): """Collection compose of a custom domain resources list and a possible link for next page. :ivar value: The custom domain resources list. @@ -1093,16 +1026,12 @@ class CustomDomainResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CustomDomainResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CustomDomainResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The custom domain resources list. @@ -1110,43 +1039,38 @@ def __init__( :keyword next_link: The link to next page of custom domain list. :paramtype next_link: str """ - super(CustomDomainResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CustomDomainValidatePayload(msrest.serialization.Model): +class CustomDomainValidatePayload(_serialization.Model): """Custom domain validate payload. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name to be validated. + :ivar name: Name to be validated. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Name to be validated. + :keyword name: Name to be validated. Required. :paramtype name: str """ - super(CustomDomainValidatePayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CustomDomainValidateResult(msrest.serialization.Model): +class CustomDomainValidateResult(_serialization.Model): """Validation result for custom domain. :ivar is_valid: Indicates if domain name is valid. @@ -1156,29 +1080,23 @@ class CustomDomainValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'message': {'key': 'message', 'type': 'str'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - is_valid: Optional[bool] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, is_valid: Optional[bool] = None, message: Optional[str] = None, **kwargs): """ :keyword is_valid: Indicates if domain name is valid. :paramtype is_valid: bool :keyword message: Message of why domain name is invalid. :paramtype message: str """ - super(CustomDomainValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.message = message -class DeploymentInstance(msrest.serialization.Model): +class DeploymentInstance(_serialization.Model): """Deployment instance payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1196,28 +1114,24 @@ class DeploymentInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, - 'reason': {'readonly': True}, - 'discovery_status': {'readonly': True}, - 'start_time': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, + "reason": {"readonly": True}, + "discovery_status": {"readonly": True}, + "start_time": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'discovery_status': {'key': 'discoveryStatus', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "discovery_status": {"key": "discoveryStatus", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None self.reason = None @@ -1243,24 +1157,24 @@ class DeploymentResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( self, *, - properties: Optional["DeploymentResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.DeploymentResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -1269,12 +1183,12 @@ def __init__( :keyword sku: Sku of the Deployment resource. :paramtype sku: ~azure.mgmt.appplatform.v2020_07_01.models.Sku """ - super(DeploymentResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.sku = sku -class DeploymentResourceCollection(msrest.serialization.Model): +class DeploymentResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of Deployment resources. @@ -1285,16 +1199,12 @@ class DeploymentResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["DeploymentResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.DeploymentResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Deployment resources. @@ -1303,12 +1213,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(DeploymentResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class DeploymentResourceProperties(msrest.serialization.Model): +class DeploymentResourceProperties(_serialization.Model): """Deployment resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1319,12 +1229,12 @@ class DeploymentResourceProperties(msrest.serialization.Model): :vartype app_name: str :ivar deployment_settings: Deployment settings of the Deployment. :vartype deployment_settings: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentSettings - :ivar provisioning_state: Provisioning state of the Deployment. Possible values include: - "Creating", "Updating", "Succeeded", "Failed". + :ivar provisioning_state: Provisioning state of the Deployment. Known values are: "Creating", + "Updating", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResourceProvisioningState - :ivar status: Status of the Deployment. Possible values include: "Unknown", "Stopped", - "Running", "Failed", "Allocating", "Upgrading", "Compiling". + :ivar status: Status of the Deployment. Known values are: "Unknown", "Stopped", "Running", + "Failed", "Allocating", "Upgrading", and "Compiling". :vartype status: str or ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResourceStatus :ivar active: Indicates whether the Deployment is active. :vartype active: bool @@ -1335,30 +1245,30 @@ class DeploymentResourceProperties(msrest.serialization.Model): """ _validation = { - 'app_name': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'active': {'readonly': True}, - 'created_time': {'readonly': True}, - 'instances': {'readonly': True}, + "app_name": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "active": {"readonly": True}, + "created_time": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'UserSourceInfo'}, - 'app_name': {'key': 'appName', 'type': 'str'}, - 'deployment_settings': {'key': 'deploymentSettings', 'type': 'DeploymentSettings'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'active': {'key': 'active', 'type': 'bool'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'instances': {'key': 'instances', 'type': '[DeploymentInstance]'}, + "source": {"key": "source", "type": "UserSourceInfo"}, + "app_name": {"key": "appName", "type": "str"}, + "deployment_settings": {"key": "deploymentSettings", "type": "DeploymentSettings"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "active": {"key": "active", "type": "bool"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "instances": {"key": "instances", "type": "[DeploymentInstance]"}, } def __init__( self, *, - source: Optional["UserSourceInfo"] = None, - deployment_settings: Optional["DeploymentSettings"] = None, + source: Optional["_models.UserSourceInfo"] = None, + deployment_settings: Optional["_models.DeploymentSettings"] = None, **kwargs ): """ @@ -1367,7 +1277,7 @@ def __init__( :keyword deployment_settings: Deployment settings of the Deployment. :paramtype deployment_settings: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentSettings """ - super(DeploymentResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.app_name = None self.deployment_settings = deployment_settings @@ -1378,7 +1288,7 @@ def __init__( self.instances = None -class DeploymentSettings(msrest.serialization.Model): +class DeploymentSettings(_serialization.Model): """Deployment settings payload. :ivar cpu: Required CPU, basic tier should be 1, standard tier should be in range (1, 4). @@ -1392,29 +1302,29 @@ class DeploymentSettings(msrest.serialization.Model): :vartype net_core_main_entry_path: str :ivar environment_variables: Collection of environment variables. :vartype environment_variables: dict[str, str] - :ivar runtime_version: Runtime version. Possible values include: "Java_8", "Java_11", - "NetCore_31". Default value: "Java_8". + :ivar runtime_version: Runtime version. Known values are: "Java_8", "Java_11", and + "NetCore_31". :vartype runtime_version: str or ~azure.mgmt.appplatform.v2020_07_01.models.RuntimeVersion """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'int'}, - 'memory_in_gb': {'key': 'memoryInGB', 'type': 'int'}, - 'jvm_options': {'key': 'jvmOptions', 'type': 'str'}, - 'net_core_main_entry_path': {'key': 'netCoreMainEntryPath', 'type': 'str'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '{str}'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "int"}, + "memory_in_gb": {"key": "memoryInGB", "type": "int"}, + "jvm_options": {"key": "jvmOptions", "type": "str"}, + "net_core_main_entry_path": {"key": "netCoreMainEntryPath", "type": "str"}, + "environment_variables": {"key": "environmentVariables", "type": "{str}"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, } def __init__( self, *, - cpu: Optional[int] = 1, - memory_in_gb: Optional[int] = 1, + cpu: int = 1, + memory_in_gb: int = 1, jvm_options: Optional[str] = None, net_core_main_entry_path: Optional[str] = None, environment_variables: Optional[Dict[str, str]] = None, - runtime_version: Optional[Union[str, "RuntimeVersion"]] = "Java_8", + runtime_version: Union[str, "_models.RuntimeVersion"] = "Java_8", **kwargs ): """ @@ -1429,11 +1339,11 @@ def __init__( :paramtype net_core_main_entry_path: str :keyword environment_variables: Collection of environment variables. :paramtype environment_variables: dict[str, str] - :keyword runtime_version: Runtime version. Possible values include: "Java_8", "Java_11", - "NetCore_31". Default value: "Java_8". + :keyword runtime_version: Runtime version. Known values are: "Java_8", "Java_11", and + "NetCore_31". :paramtype runtime_version: str or ~azure.mgmt.appplatform.v2020_07_01.models.RuntimeVersion """ - super(DeploymentSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory_in_gb = memory_in_gb self.jvm_options = jvm_options @@ -1442,7 +1352,7 @@ def __init__( self.runtime_version = runtime_version -class Error(msrest.serialization.Model): +class Error(_serialization.Model): """The error code compose of code and message. :ivar code: The code of error. @@ -1452,38 +1362,32 @@ class Error(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: The code of error. :paramtype code: str :keyword message: The message of error. :paramtype message: str """ - super(Error, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class GitPatternRepository(msrest.serialization.Model): +class GitPatternRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes """Git repository property payload. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the repository. + :ivar name: Name of the repository. Required. :vartype name: str :ivar pattern: Collection of pattern of the repository. :vartype pattern: list[str] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -1504,22 +1408,22 @@ class GitPatternRepository(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'uri': {'required': True}, + "name": {"required": True}, + "uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'pattern': {'key': 'pattern', 'type': '[str]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "pattern": {"key": "pattern", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( @@ -1539,11 +1443,11 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of the repository. + :keyword name: Name of the repository. Required. :paramtype name: str :keyword pattern: Collection of pattern of the repository. :paramtype pattern: list[str] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -1562,7 +1466,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(GitPatternRepository, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.pattern = pattern self.uri = uri @@ -1576,38 +1480,33 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class LogFileUrlResponse(msrest.serialization.Model): +class LogFileUrlResponse(_serialization.Model): """Log file URL payload. All required parameters must be populated in order to send to Azure. - :ivar url: Required. URL of the log file. + :ivar url: URL of the log file. Required. :vartype url: str """ _validation = { - 'url': {'required': True}, + "url": {"required": True}, } _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, } - def __init__( - self, - *, - url: str, - **kwargs - ): + def __init__(self, *, url: str, **kwargs): """ - :keyword url: Required. URL of the log file. + :keyword url: URL of the log file. Required. :paramtype url: str """ - super(LogFileUrlResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url -class LogSpecification(msrest.serialization.Model): +class LogSpecification(_serialization.Model): """Specifications of the Log for Azure Monitoring. :ivar name: Name of the log. @@ -1619,9 +1518,9 @@ class LogSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, } def __init__( @@ -1640,17 +1539,17 @@ def __init__( :keyword blob_duration: Blob duration of the log. :paramtype blob_duration: str """ - super(LogSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class ManagedIdentityProperties(msrest.serialization.Model): +class ManagedIdentityProperties(_serialization.Model): """Managed identity properties retrieved from ARM request headers. - :ivar type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.appplatform.v2020_07_01.models.ManagedIdentityType :ivar principal_id: Principal Id. :vartype principal_id: str @@ -1659,35 +1558,35 @@ class ManagedIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ManagedIdentityType"]] = None, + type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs ): """ - :keyword type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.appplatform.v2020_07_01.models.ManagedIdentityType :keyword principal_id: Principal Id. :paramtype principal_id: str :keyword tenant_id: Tenant Id. :paramtype tenant_id: str """ - super(ManagedIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.principal_id = principal_id self.tenant_id = tenant_id -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """Specifications of the Dimension of metrics. :ivar name: Name of the dimension. @@ -1700,9 +1599,9 @@ class MetricDimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -1722,13 +1621,13 @@ def __init__( export scenario. :paramtype to_be_exported_for_shoebox: bool """ - super(MetricDimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes """Specifications of the Metrics for Azure Monitoring. :ivar name: Name of the metric. @@ -1759,17 +1658,17 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "source_mdm_namespace": {"key": "sourceMdmNamespace", "type": "str"}, } def __init__( @@ -1784,7 +1683,7 @@ def __init__( supported_aggregation_types: Optional[List[str]] = None, supported_time_grain_types: Optional[List[str]] = None, fill_gap_with_zero: Optional[bool] = None, - dimensions: Optional[List["MetricDimension"]] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, source_mdm_namespace: Optional[str] = None, **kwargs ): @@ -1815,7 +1714,7 @@ def __init__( :keyword source_mdm_namespace: Name of the MDM namespace. Optional. :paramtype source_mdm_namespace: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1829,13 +1728,13 @@ def __init__( self.source_mdm_namespace = source_mdm_namespace -class MonitoringSettingProperties(msrest.serialization.Model): +class MonitoringSettingProperties(_serialization.Model): """Monitoring Setting properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Monitoring Setting. Possible values include: - "NotAvailable", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the Monitoring Setting. Known values are: "NotAvailable", + "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingState :ivar error: Error when apply Monitoring Setting changes. @@ -1847,20 +1746,20 @@ class MonitoringSettingProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'trace_enabled': {'key': 'traceEnabled', 'type': 'bool'}, - 'app_insights_instrumentation_key': {'key': 'appInsightsInstrumentationKey', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "trace_enabled": {"key": "traceEnabled", "type": "bool"}, + "app_insights_instrumentation_key": {"key": "appInsightsInstrumentationKey", "type": "str"}, } def __init__( self, *, - error: Optional["Error"] = None, + error: Optional["_models.Error"] = None, trace_enabled: Optional[bool] = None, app_insights_instrumentation_key: Optional[str] = None, **kwargs @@ -1873,7 +1772,7 @@ def __init__( :keyword app_insights_instrumentation_key: Target application insight instrumentation key. :paramtype app_insights_instrumentation_key: str """ - super(MonitoringSettingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.trace_enabled = trace_enabled @@ -1896,33 +1795,28 @@ class MonitoringSettingResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'MonitoringSettingProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "MonitoringSettingProperties"}, } - def __init__( - self, - *, - properties: Optional["MonitoringSettingProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.MonitoringSettingProperties"] = None, **kwargs): """ :keyword properties: Properties of the Monitoring Setting resource. :paramtype properties: ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingProperties """ - super(MonitoringSettingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class NameAvailability(msrest.serialization.Model): +class NameAvailability(_serialization.Model): """Name availability result payload. :ivar name_available: Indicates whether the name is available. @@ -1934,9 +1828,9 @@ class NameAvailability(msrest.serialization.Model): """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } def __init__( @@ -1955,52 +1849,46 @@ def __init__( :keyword message: Message why the name is not available. :paramtype message: str """ - super(NameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class NameAvailabilityParameters(msrest.serialization.Model): +class NameAvailabilityParameters(_serialization.Model): """Name availability parameters payload. All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the resource to check name availability. + :ivar type: Type of the resource to check name availability. Required. :vartype type: str - :ivar name: Required. Name to be checked. + :ivar name: Name to be checked. Required. :vartype name: str """ _validation = { - 'type': {'required': True}, - 'name': {'required': True}, + "type": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - type: str, - name: str, - **kwargs - ): + def __init__(self, *, type: str, name: str, **kwargs): """ - :keyword type: Required. Type of the resource to check name availability. + :keyword type: Type of the resource to check name availability. Required. :paramtype type: str - :keyword name: Required. Name to be checked. + :keyword name: Name to be checked. Required. :paramtype name: str """ - super(NameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class NetworkProfile(msrest.serialization.Model): +class NetworkProfile(_serialization.Model): """Service network profile payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2025,18 +1913,18 @@ class NetworkProfile(msrest.serialization.Model): """ _validation = { - 'outbound_i_ps': {'readonly': True}, - 'required_traffics': {'readonly': True}, + "outbound_i_ps": {"readonly": True}, + "required_traffics": {"readonly": True}, } _attribute_map = { - 'service_runtime_subnet_id': {'key': 'serviceRuntimeSubnetId', 'type': 'str'}, - 'app_subnet_id': {'key': 'appSubnetId', 'type': 'str'}, - 'service_cidr': {'key': 'serviceCidr', 'type': 'str'}, - 'service_runtime_network_resource_group': {'key': 'serviceRuntimeNetworkResourceGroup', 'type': 'str'}, - 'app_network_resource_group': {'key': 'appNetworkResourceGroup', 'type': 'str'}, - 'outbound_i_ps': {'key': 'outboundIPs', 'type': 'NetworkProfileOutboundIPs'}, - 'required_traffics': {'key': 'requiredTraffics', 'type': '[RequiredTraffic]'}, + "service_runtime_subnet_id": {"key": "serviceRuntimeSubnetId", "type": "str"}, + "app_subnet_id": {"key": "appSubnetId", "type": "str"}, + "service_cidr": {"key": "serviceCidr", "type": "str"}, + "service_runtime_network_resource_group": {"key": "serviceRuntimeNetworkResourceGroup", "type": "str"}, + "app_network_resource_group": {"key": "appNetworkResourceGroup", "type": "str"}, + "outbound_i_ps": {"key": "outboundIPs", "type": "NetworkProfileOutboundIPs"}, + "required_traffics": {"key": "requiredTraffics", "type": "[RequiredTraffic]"}, } def __init__( @@ -2065,7 +1953,7 @@ def __init__( Azure Spring Cloud Apps. :paramtype app_network_resource_group: str """ - super(NetworkProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_runtime_subnet_id = service_runtime_subnet_id self.app_subnet_id = app_subnet_id self.service_cidr = service_cidr @@ -2075,7 +1963,7 @@ def __init__( self.required_traffics = None -class NetworkProfileOutboundIPs(msrest.serialization.Model): +class NetworkProfileOutboundIPs(_serialization.Model): """Desired outbound IP resources for Azure Spring Cloud instance. Variables are only populated by the server, and will be ignored when sending a request. @@ -2085,24 +1973,20 @@ class NetworkProfileOutboundIPs(msrest.serialization.Model): """ _validation = { - 'public_i_ps': {'readonly': True}, + "public_i_ps": {"readonly": True}, } _attribute_map = { - 'public_i_ps': {'key': 'publicIPs', 'type': '[str]'}, + "public_i_ps": {"key": "publicIPs", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(NetworkProfileOutboundIPs, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.public_i_ps = None -class OperationDetail(msrest.serialization.Model): +class OperationDetail(_serialization.Model): """Operation detail payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2114,7 +1998,7 @@ class OperationDetail(msrest.serialization.Model): :ivar display: Display of the operation. :vartype display: ~azure.mgmt.appplatform.v2020_07_01.models.OperationDisplay :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. Possible values include: "Internal". + internal only APIs. "Internal" :vartype action_type: str or ~azure.mgmt.appplatform.v2020_07_01.models.ActionType :ivar origin: Origin of the operation. :vartype origin: str @@ -2123,16 +2007,16 @@ class OperationDetail(msrest.serialization.Model): """ _validation = { - 'action_type': {'readonly': True}, + "action_type": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'action_type': {'key': 'actionType', 'type': 'str'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "action_type": {"key": "actionType", "type": "str"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "OperationProperties"}, } def __init__( @@ -2140,9 +2024,9 @@ 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, - properties: Optional["OperationProperties"] = None, + properties: Optional["_models.OperationProperties"] = None, **kwargs ): """ @@ -2157,7 +2041,7 @@ def __init__( :keyword properties: Properties of the operation. :paramtype properties: ~azure.mgmt.appplatform.v2020_07_01.models.OperationProperties """ - super(OperationDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display @@ -2166,7 +2050,7 @@ def __init__( self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display payload. :ivar provider: Resource provider of the operation. @@ -2180,10 +2064,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__( @@ -2205,14 +2089,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 OperationProperties(msrest.serialization.Model): +class OperationProperties(_serialization.Model): """Extra Operation properties. :ivar service_specification: Service specifications of the operation. @@ -2220,25 +2104,20 @@ class OperationProperties(msrest.serialization.Model): """ _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, } - def __init__( - self, - *, - service_specification: Optional["ServiceSpecification"] = None, - **kwargs - ): + def __init__(self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs): """ :keyword service_specification: Service specifications of the operation. :paramtype service_specification: ~azure.mgmt.appplatform.v2020_07_01.models.ServiceSpecification """ - super(OperationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_specification = service_specification -class PersistentDisk(msrest.serialization.Model): +class PersistentDisk(_serialization.Model): """Persistent disk payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2252,69 +2131,56 @@ class PersistentDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 50, 'minimum': 0}, - 'used_in_gb': {'readonly': True, 'maximum': 50, 'minimum': 0}, + "size_in_gb": {"maximum": 50, "minimum": 0}, + "used_in_gb": {"readonly": True, "maximum": 50, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'used_in_gb': {'key': 'usedInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "used_in_gb": {"key": "usedInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: Optional[str] = None, **kwargs): """ :keyword size_in_gb: Size of the persistent disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the persistent disk. :paramtype mount_path: str """ - super(PersistentDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.used_in_gb = None self.mount_path = mount_path -class RegenerateTestKeyRequestPayload(msrest.serialization.Model): +class RegenerateTestKeyRequestPayload(_serialization.Model): """Regenerate test key request payload. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :ivar key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :vartype key_type: str or ~azure.mgmt.appplatform.v2020_07_01.models.TestKeyType """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "TestKeyType"], - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.TestKeyType"], **kwargs): """ - :keyword key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :keyword key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :paramtype key_type: str or ~azure.mgmt.appplatform.v2020_07_01.models.TestKeyType """ - super(RegenerateTestKeyRequestPayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type -class RequiredTraffic(msrest.serialization.Model): +class RequiredTraffic(_serialization.Model): """Required inbound or outbound traffic for Azure Spring Cloud instance. Variables are only populated by the server, and will be ignored when sending a request. @@ -2327,34 +2193,29 @@ class RequiredTraffic(msrest.serialization.Model): :vartype ips: list[str] :ivar fqdns: The FQDN list of required traffic. :vartype fqdns: list[str] - :ivar direction: The direction of required traffic. Possible values include: "Inbound", - "Outbound". + :ivar direction: The direction of required traffic. Known values are: "Inbound" and "Outbound". :vartype direction: str or ~azure.mgmt.appplatform.v2020_07_01.models.TrafficDirection """ _validation = { - 'protocol': {'readonly': True}, - 'port': {'readonly': True}, - 'ips': {'readonly': True}, - 'fqdns': {'readonly': True}, - 'direction': {'readonly': True}, + "protocol": {"readonly": True}, + "port": {"readonly": True}, + "ips": {"readonly": True}, + "fqdns": {"readonly": True}, + "direction": {"readonly": True}, } _attribute_map = { - 'protocol': {'key': 'protocol', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - 'ips': {'key': 'ips', 'type': '[str]'}, - 'fqdns': {'key': 'fqdns', 'type': '[str]'}, - 'direction': {'key': 'direction', 'type': 'str'}, + "protocol": {"key": "protocol", "type": "str"}, + "port": {"key": "port", "type": "int"}, + "ips": {"key": "ips", "type": "[str]"}, + "fqdns": {"key": "fqdns", "type": "[str]"}, + "direction": {"key": "direction", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RequiredTraffic, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.protocol = None self.port = None self.ips = None @@ -2362,7 +2223,7 @@ def __init__( self.direction = None -class ResourceSku(msrest.serialization.Model): +class ResourceSku(_serialization.Model): """Describes an available Azure Spring Cloud SKU. :ivar resource_type: Gets the type of resource the SKU applies to. @@ -2385,13 +2246,13 @@ class ResourceSku(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'SkuCapacity'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[ResourceSkuLocationInfo]'}, - 'restrictions': {'key': 'restrictions', 'type': '[ResourceSkuRestrictions]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "SkuCapacity"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[ResourceSkuLocationInfo]"}, + "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, } def __init__( @@ -2400,10 +2261,10 @@ def __init__( resource_type: Optional[str] = None, name: Optional[str] = None, tier: Optional[str] = None, - capacity: Optional["SkuCapacity"] = None, + capacity: Optional["_models.SkuCapacity"] = None, locations: Optional[List[str]] = None, - location_info: Optional[List["ResourceSkuLocationInfo"]] = None, - restrictions: Optional[List["ResourceSkuRestrictions"]] = None, + location_info: Optional[List["_models.ResourceSkuLocationInfo"]] = None, + restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None, **kwargs ): """ @@ -2426,7 +2287,7 @@ def __init__( :paramtype restrictions: list[~azure.mgmt.appplatform.v2020_07_01.models.ResourceSkuRestrictions] """ - super(ResourceSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.name = name self.tier = tier @@ -2436,7 +2297,7 @@ def __init__( self.restrictions = restrictions -class ResourceSkuCapabilities(msrest.serialization.Model): +class ResourceSkuCapabilities(_serialization.Model): """ResourceSkuCapabilities. :ivar name: Gets an invariant to describe the feature. @@ -2446,29 +2307,23 @@ class ResourceSkuCapabilities(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: Gets an invariant to describe the feature. :paramtype name: str :keyword value: Gets an invariant if the feature is measured by quantity. :paramtype value: str """ - super(ResourceSkuCapabilities, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class ResourceSkuCollection(msrest.serialization.Model): +class ResourceSkuCollection(_serialization.Model): """Object that includes an array of Azure Spring Cloud SKU and a possible link for next set. :ivar value: Collection of resource SKU. @@ -2479,16 +2334,12 @@ class ResourceSkuCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ResourceSku"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ResourceSku"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of resource SKU. @@ -2497,12 +2348,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ResourceSkuCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ResourceSkuLocationInfo(msrest.serialization.Model): +class ResourceSkuLocationInfo(_serialization.Model): """Locations and availability zones where the SKU is available. :ivar location: Gets location of the SKU. @@ -2514,9 +2365,9 @@ class ResourceSkuLocationInfo(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'zone_details': {'key': 'zoneDetails', 'type': '[ResourceSkuZoneDetails]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "zone_details": {"key": "zoneDetails", "type": "[ResourceSkuZoneDetails]"}, } def __init__( @@ -2524,7 +2375,7 @@ def __init__( *, location: Optional[str] = None, zones: Optional[List[str]] = None, - zone_details: Optional[List["ResourceSkuZoneDetails"]] = None, + zone_details: Optional[List["_models.ResourceSkuZoneDetails"]] = None, **kwargs ): """ @@ -2536,13 +2387,13 @@ def __init__( :paramtype zone_details: list[~azure.mgmt.appplatform.v2020_07_01.models.ResourceSkuZoneDetails] """ - super(ResourceSkuLocationInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones self.zone_details = zone_details -class ResourceSkuRestrictionInfo(msrest.serialization.Model): +class ResourceSkuRestrictionInfo(_serialization.Model): """Information about the restriction where the SKU cannot be used. :ivar locations: Gets locations where the SKU is restricted. @@ -2552,33 +2403,27 @@ class ResourceSkuRestrictionInfo(msrest.serialization.Model): """ _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - locations: Optional[List[str]] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, locations: Optional[List[str]] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword locations: Gets locations where the SKU is restricted. :paramtype locations: list[str] :keyword zones: Gets list of availability zones where the SKU is restricted. :paramtype zones: list[str] """ - super(ResourceSkuRestrictionInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.locations = locations self.zones = zones -class ResourceSkuRestrictions(msrest.serialization.Model): +class ResourceSkuRestrictions(_serialization.Model): """Restrictions where the SKU cannot be used. - :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. Known + values are: "Location" and "Zone". :vartype type: str or ~azure.mgmt.appplatform.v2020_07_01.models.ResourceSkuRestrictionsType :ivar values: Gets the value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted. @@ -2588,31 +2433,30 @@ class ResourceSkuRestrictions(msrest.serialization.Model): :vartype restriction_info: ~azure.mgmt.appplatform.v2020_07_01.models.ResourceSkuRestrictionInfo :ivar reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.appplatform.v2020_07_01.models.ResourceSkuRestrictionsReasonCode """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'ResourceSkuRestrictionInfo'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "restriction_info": {"key": "restrictionInfo", "type": "ResourceSkuRestrictionInfo"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceSkuRestrictionsType"]] = None, + type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None, values: Optional[List[str]] = None, - restriction_info: Optional["ResourceSkuRestrictionInfo"] = None, - reason_code: Optional[Union[str, "ResourceSkuRestrictionsReasonCode"]] = None, + restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None, + reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None, **kwargs ): """ :keyword type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + Known values are: "Location" and "Zone". :paramtype type: str or ~azure.mgmt.appplatform.v2020_07_01.models.ResourceSkuRestrictionsType :keyword values: Gets the value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted. @@ -2622,19 +2466,18 @@ def __init__( :paramtype restriction_info: ~azure.mgmt.appplatform.v2020_07_01.models.ResourceSkuRestrictionInfo :keyword reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.appplatform.v2020_07_01.models.ResourceSkuRestrictionsReasonCode """ - super(ResourceSkuRestrictions, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.values = values self.restriction_info = restriction_info self.reason_code = reason_code -class ResourceSkuZoneDetails(msrest.serialization.Model): +class ResourceSkuZoneDetails(_serialization.Model): """Details of capabilities available to a SKU in specific zones. :ivar name: Gets the set of zones that the SKU is available in with the @@ -2646,15 +2489,15 @@ class ResourceSkuZoneDetails(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[ResourceSkuCapabilities]'}, + "name": {"key": "name", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, } def __init__( self, *, name: Optional[List[str]] = None, - capabilities: Optional[List["ResourceSkuCapabilities"]] = None, + capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None, **kwargs ): """ @@ -2666,12 +2509,12 @@ def __init__( :paramtype capabilities: list[~azure.mgmt.appplatform.v2020_07_01.models.ResourceSkuCapabilities] """ - super(ResourceSkuZoneDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.capabilities = capabilities -class ResourceUploadDefinition(msrest.serialization.Model): +class ResourceUploadDefinition(_serialization.Model): """Resource upload definition payload. :ivar relative_path: Source relative path. @@ -2681,24 +2524,18 @@ class ResourceUploadDefinition(msrest.serialization.Model): """ _attribute_map = { - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'upload_url': {'key': 'uploadUrl', 'type': 'str'}, + "relative_path": {"key": "relativePath", "type": "str"}, + "upload_url": {"key": "uploadUrl", "type": "str"}, } - def __init__( - self, - *, - relative_path: Optional[str] = None, - upload_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, relative_path: Optional[str] = None, upload_url: Optional[str] = None, **kwargs): """ :keyword relative_path: Source relative path. :paramtype relative_path: str :keyword upload_url: Upload URL. :paramtype upload_url: str """ - super(ResourceUploadDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.relative_path = relative_path self.upload_url = upload_url @@ -2716,40 +2553,33 @@ class TrackedResource(Resource): :vartype type: str :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -2767,8 +2597,7 @@ class ServiceResource(TrackedResource): :vartype type: str :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] :ivar properties: Properties of the Service resource. :vartype properties: ~azure.mgmt.appplatform.v2020_07_01.models.ClusterResourceProperties @@ -2777,19 +2606,19 @@ class ServiceResource(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ClusterResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "ClusterResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( @@ -2797,27 +2626,27 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - properties: Optional["ClusterResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.ClusterResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] :keyword properties: Properties of the Service resource. :paramtype properties: ~azure.mgmt.appplatform.v2020_07_01.models.ClusterResourceProperties :keyword sku: Sku of the Service resource. :paramtype sku: ~azure.mgmt.appplatform.v2020_07_01.models.Sku """ - super(ServiceResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.properties = properties self.sku = sku -class ServiceResourceList(msrest.serialization.Model): +class ServiceResourceList(_serialization.Model): """Object that includes an array of Service resources and a possible link for next set. :ivar value: Collection of Service resources. @@ -2828,16 +2657,12 @@ class ServiceResourceList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ServiceResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ServiceResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Service resources. @@ -2846,12 +2671,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ServiceResourceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification payload. :ivar log_specifications: Specifications of the Log for Azure Monitoring. @@ -2862,15 +2687,15 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } def __init__( self, *, - log_specifications: Optional[List["LogSpecification"]] = None, - metric_specifications: Optional[List["MetricSpecification"]] = None, + log_specifications: Optional[List["_models.LogSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -2881,12 +2706,12 @@ def __init__( :paramtype metric_specifications: list[~azure.mgmt.appplatform.v2020_07_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_specifications = log_specifications self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """Sku of Azure Spring Cloud. :ivar name: Name of the Sku. @@ -2898,18 +2723,13 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( - self, - *, - name: Optional[str] = None, - tier: Optional[str] = None, - capacity: Optional[int] = None, - **kwargs + self, *, name: Optional[str] = None, tier: Optional[str] = None, capacity: Optional[int] = None, **kwargs ): """ :keyword name: Name of the Sku. @@ -2919,37 +2739,37 @@ def __init__( :keyword capacity: Current capacity of the target resource. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SkuCapacity(msrest.serialization.Model): +class SkuCapacity(_serialization.Model): """The SKU capacity. All required parameters must be populated in order to send to Azure. - :ivar minimum: Required. Gets or sets the minimum. + :ivar minimum: Gets or sets the minimum. Required. :vartype minimum: int :ivar maximum: Gets or sets the maximum. :vartype maximum: int :ivar default: Gets or sets the default. :vartype default: int - :ivar scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :ivar scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", and + "Automatic". :vartype scale_type: str or ~azure.mgmt.appplatform.v2020_07_01.models.SkuScaleType """ _validation = { - 'minimum': {'required': True}, + "minimum": {"required": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } def __init__( @@ -2958,71 +2778,71 @@ def __init__( minimum: int, maximum: Optional[int] = None, default: Optional[int] = None, - scale_type: Optional[Union[str, "SkuScaleType"]] = None, + scale_type: Optional[Union[str, "_models.SkuScaleType"]] = None, **kwargs ): """ - :keyword minimum: Required. Gets or sets the minimum. + :keyword minimum: Gets or sets the minimum. Required. :paramtype minimum: int :keyword maximum: Gets or sets the maximum. :paramtype maximum: int :keyword default: Gets or sets the default. :paramtype default: int - :keyword scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :keyword scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", + and "Automatic". :paramtype scale_type: str or ~azure.mgmt.appplatform.v2020_07_01.models.SkuScaleType """ - super(SkuCapacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.minimum = minimum self.maximum = maximum self.default = default self.scale_type = scale_type -class SupportedRuntimeVersion(msrest.serialization.Model): +class SupportedRuntimeVersion(_serialization.Model): """Supported deployment runtime version descriptor. - :ivar value: The raw value which could be passed to deployment CRUD operations. Possible values - include: "Java_8", "Java_11", "NetCore_31". + :ivar value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", and "NetCore_31". :vartype value: str or ~azure.mgmt.appplatform.v2020_07_01.models.SupportedRuntimeValue - :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). Known + values are: "Java" and ".NET Core". :vartype platform: str or ~azure.mgmt.appplatform.v2020_07_01.models.SupportedRuntimePlatform :ivar version: The detailed version (major.minor) of the platform. :vartype version: str """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'platform': {'key': 'platform', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "platform": {"key": "platform", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - value: Optional[Union[str, "SupportedRuntimeValue"]] = None, - platform: Optional[Union[str, "SupportedRuntimePlatform"]] = None, + value: Optional[Union[str, "_models.SupportedRuntimeValue"]] = None, + platform: Optional[Union[str, "_models.SupportedRuntimePlatform"]] = None, version: Optional[str] = None, **kwargs ): """ - :keyword value: The raw value which could be passed to deployment CRUD operations. Possible - values include: "Java_8", "Java_11", "NetCore_31". + :keyword value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", and "NetCore_31". :paramtype value: str or ~azure.mgmt.appplatform.v2020_07_01.models.SupportedRuntimeValue :keyword platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + Known values are: "Java" and ".NET Core". :paramtype platform: str or ~azure.mgmt.appplatform.v2020_07_01.models.SupportedRuntimePlatform :keyword version: The detailed version (major.minor) of the platform. :paramtype version: str """ - super(SupportedRuntimeVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.platform = platform self.version = version -class TemporaryDisk(msrest.serialization.Model): +class TemporaryDisk(_serialization.Model): """Temporary disk payload. :ivar size_in_gb: Size of the temporary disk in GB. @@ -3032,33 +2852,27 @@ class TemporaryDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 5, 'minimum': 0}, + "size_in_gb": {"maximum": 5, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = "/tmp", - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: str = "/tmp", **kwargs): """ :keyword size_in_gb: Size of the temporary disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the temporary disk. :paramtype mount_path: str """ - super(TemporaryDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.mount_path = mount_path -class TestKeys(msrest.serialization.Model): +class TestKeys(_serialization.Model): """Test keys payload. :ivar primary_key: Primary key. @@ -3074,11 +2888,11 @@ class TestKeys(msrest.serialization.Model): """ _attribute_map = { - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'primary_test_endpoint': {'key': 'primaryTestEndpoint', 'type': 'str'}, - 'secondary_test_endpoint': {'key': 'secondaryTestEndpoint', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "primary_test_endpoint": {"key": "primaryTestEndpoint", "type": "str"}, + "secondary_test_endpoint": {"key": "secondaryTestEndpoint", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, } def __init__( @@ -3103,7 +2917,7 @@ def __init__( :keyword enabled: Indicates whether the test endpoint feature enabled or not. :paramtype enabled: bool """ - super(TestKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_key = primary_key self.secondary_key = secondary_key self.primary_test_endpoint = primary_test_endpoint @@ -3111,11 +2925,10 @@ def __init__( self.enabled = enabled -class UserSourceInfo(msrest.serialization.Model): +class UserSourceInfo(_serialization.Model): """Source information for a deployment. - :ivar type: Type of the source uploaded. Possible values include: "Jar", "NetCoreZip", - "Source". + :ivar type: Type of the source uploaded. Known values are: "Jar", "NetCoreZip", and "Source". :vartype type: str or ~azure.mgmt.appplatform.v2020_07_01.models.UserSourceType :ivar relative_path: Relative path of the storage which stores the source. :vartype relative_path: str @@ -3128,23 +2941,23 @@ class UserSourceInfo(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'artifact_selector': {'key': 'artifactSelector', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "artifact_selector": {"key": "artifactSelector", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "UserSourceType"]] = None, + type: Optional[Union[str, "_models.UserSourceType"]] = None, relative_path: Optional[str] = None, version: Optional[str] = None, artifact_selector: Optional[str] = None, **kwargs ): """ - :keyword type: Type of the source uploaded. Possible values include: "Jar", "NetCoreZip", + :keyword type: Type of the source uploaded. Known values are: "Jar", "NetCoreZip", and "Source". :paramtype type: str or ~azure.mgmt.appplatform.v2020_07_01.models.UserSourceType :keyword relative_path: Relative path of the storage which stores the source. @@ -3156,7 +2969,7 @@ def __init__( the relative path to the target module/project. :paramtype artifact_selector: str """ - super(UserSourceInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.relative_path = relative_path self.version = version diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/__init__.py index aa6fe5cd0cfc..a3674f282ddb 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/__init__.py @@ -18,16 +18,22 @@ from ._runtime_versions_operations import RuntimeVersionsOperations from ._skus_operations import SkusOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', + "ServicesOperations", + "ConfigServersOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_apps_operations.py index 09cccf2f395b..be4360d0ea50 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_apps_operations.py @@ -6,341 +6,299 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, sync_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 sync_status is not None: - _query_parameters['syncStatus'] = _SERIALIZER.query("sync_status", sync_status, 'str') + _params["syncStatus"] = _SERIALIZER.query("sync_status", sync_status, "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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01") # type: str +def build_list_request(resource_group_name: str, service_name: str, 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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_resource_upload_url_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_validate_domain_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class AppsOperations(object): - """AppsOperations 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.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.AppPlatformManagementClient`'s + :attr:`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 get( @@ -350,102 +308,121 @@ def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(app_resource, 'AppResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - 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(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -453,21 +430,98 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_07_01.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -475,20 +529,24 @@ def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2020_07_01.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_07_01.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -500,84 +558,91 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either AppResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.AppResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -587,25 +652,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -617,83 +677,103 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(app_resource, 'AppResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -701,18 +781,95 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_07_01.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -720,20 +877,24 @@ def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2020_07_01.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_07_01.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -745,104 +906,115 @@ def begin_update( :return: An instance of LROPoller that returns either AppResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.AppResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AppResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -856,10 +1028,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 @@ -869,74 +1039,135 @@ 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.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def validate_domain( @@ -944,66 +1175,84 @@ def validate_domain( resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: Union[_models.CustomDomainValidatePayload, IO], **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. :type validate_payload: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainValidatePayload + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_bindings_operations.py index ef560219299f..d92c978e1028 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_bindings_operations.py @@ -6,330 +6,298 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class BindingsOperations(object): - """BindingsOperations 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.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +305,53 @@ def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(binding_resource, 'BindingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - 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(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -377,21 +359,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +467,26 @@ def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +499,19 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.BindingResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +519,73 @@ def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -518,28 +595,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -551,46 +622,52 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _update_initial( self, @@ -598,39 +675,53 @@ def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(binding_resource, 'BindingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -638,18 +729,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +834,26 @@ def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_07_01.models.BindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +866,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.BindingResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +886,102 @@ def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +995,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 @@ -816,8 +1006,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_certificates_operations.py index 2eff878a63c1..581d1e4a0bc9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_certificates_operations.py @@ -6,308 +6,305 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - 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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 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.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.AppPlatformManagementClient`'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 get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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_resource, 'CertificateResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - 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(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -315,21 +312,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -337,20 +413,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> LROPoller["_models.CertificateResource"]: + ) -> LROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. - :type certificate_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type certificate_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -363,84 +444,91 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.CertificateResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -450,25 +538,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -480,98 +563,113 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -585,10 +683,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 @@ -598,8 +694,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_config_servers_operations.py index 354d13f4ec3f..02c8c04ae12e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_config_servers_operations.py @@ -6,311 +6,299 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_validate_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/configServers/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ConfigServersOperations(object): - """ConfigServersOperations 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.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(config_server_resource, 'ConfigServerResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -318,36 +306,114 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -360,86 +426,105 @@ def begin_update_put( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.ConfigServerResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(config_server_resource, 'ConfigServerResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -447,36 +532,114 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -489,86 +652,105 @@ def begin_update_patch( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.ConfigServerResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(config_server_settings, 'ConfigServerSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -576,36 +758,114 @@ def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: ~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerSettings + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -618,47 +878,52 @@ def begin_validate( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.ConfigServerSettingsValidateResult"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_custom_domains_operations.py index e1ab08c8fc82..ad334d51ff17 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_custom_domains_operations.py @@ -6,330 +6,298 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class CustomDomainsOperations(object): - """CustomDomainsOperations 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.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +305,53 @@ def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(domain_resource, 'CustomDomainResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - 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(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -377,21 +359,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +467,26 @@ def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. - :type domain_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +499,19 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.CustomDomainResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +519,73 @@ def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -518,28 +595,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -551,46 +622,52 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _update_initial( self, @@ -598,39 +675,53 @@ def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(domain_resource, 'CustomDomainResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -638,18 +729,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +834,26 @@ def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. - :type domain_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +866,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.CustomDomainResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +886,103 @@ def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +996,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 @@ -816,8 +1007,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_deployments_operations.py index 0685c35e7aa1..414391fd602d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_deployments_operations.py @@ -6,534 +6,516 @@ # Code generated 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, List, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_delete_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_for_cluster_request( - subscription_id: str, resource_group_name: str, service_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_start_request_initial( - subscription_id: str, +def build_start_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_stop_request_initial( - subscription_id: str, +def build_stop_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request_initial( - subscription_id: str, +def build_restart_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_get_log_file_url_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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 DeploymentsOperations(object): - """DeploymentsOperations 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.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( self, @@ -541,39 +523,53 @@ def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(deployment_resource, 'DeploymentResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - 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(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -581,21 +577,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -604,22 +685,26 @@ def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. - :type deployment_resource: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -632,19 +717,19 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.DeploymentResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -652,67 +737,73 @@ def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -722,28 +813,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -755,46 +840,52 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _update_initial( self, @@ -802,39 +893,53 @@ def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(deployment_resource, 'DeploymentResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -842,18 +947,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -862,22 +1052,26 @@ def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. - :type deployment_resource: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -890,19 +1084,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.DeploymentResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -910,32 +1104,37 @@ def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -945,60 +1144,70 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + ) -> Iterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1012,10 +1221,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 @@ -1025,69 +1232,74 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1101,10 +1313,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1114,46 +1324,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1163,28 +1372,22 @@ def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1196,81 +1399,88 @@ def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1280,28 +1490,22 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1313,81 +1517,88 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -1397,28 +1608,22 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace - def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1430,98 +1635,105 @@ def begin_restart( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1530,12 +1742,11 @@ def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_monitoring_settings_operations.py index 1b145d7f6ad7..0ca8eb2304d8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_monitoring_settings_operations.py @@ -6,267 +6,265 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 MonitoringSettingsOperations(object): - """MonitoringSettingsOperations 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.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(monitoring_setting_resource, 'MonitoringSettingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -274,37 +272,115 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -317,86 +393,105 @@ def begin_update_put( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.MonitoringSettingResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(monitoring_setting_resource, 'MonitoringSettingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -404,37 +499,115 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation 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,47 +620,52 @@ def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.MonitoringSettingResource"] - 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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_operations.py index 17678c09ffc2..2f41e32d9fa6 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_operations.py @@ -6,111 +6,130 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/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.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,10 +143,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 +154,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_runtime_versions_operations.py index 96087c600099..78335a45242c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_runtime_versions_operations.py @@ -6,117 +6,124 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from 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 -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_runtime_versions_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01") # type: str - accept = "application/json" +def build_list_runtime_versions_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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/runtimeVersions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 RuntimeVersionsOperations(object): - """RuntimeVersionsOperations 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.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_services_operations.py index 011cf1eb7f04..f3e1911b1089 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_services_operations.py @@ -6,564 +6,504 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_test_keys_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_regenerate_test_key_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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.AppPlatform/Spring/{serviceName}/regenerateTestKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_disable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_enable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_check_name_availability_request( - subscription_id: str, - location: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_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", "2020-07-01")) # type: Literal["2020-07-01"] + 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}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "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 - ) - - -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 ServicesOperations(object): - """ServicesOperations 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.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(resource, 'ServiceResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - 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(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -571,39 +511,43 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -616,81 +560,158 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] + :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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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 [202, 204]: @@ -700,22 +721,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -727,80 +742,96 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(resource, 'ServiceResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -808,36 +839,40 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -850,220 +885,371 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] + :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", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2020_07_01.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2020_07_01.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2020_07_01.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -1073,170 +1259,239 @@ def disable_test_endpoint( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace - def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def enable_test_endpoint(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - - @distributed_trace + @overload def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2020_07_01.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2020_07_01.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_07_01.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-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(availability_parameters, 'NameAvailabilityParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1250,10 +1505,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 @@ -1263,58 +1516,66 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1328,10 +1589,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 @@ -1341,8 +1600,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_skus_operations.py index 3f9b1adf699d..23826c1a0e71 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_07_01/operations/_skus_operations.py @@ -6,120 +6,135 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01")) # type: Literal["2020-07-01"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 SkusOperations(object): - """SkusOperations 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.appplatform.v2020_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_07_01.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourceSku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_07_01.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-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", "2020-07-01")) # type: Literal["2020-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -133,10 +148,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 @@ -146,8 +159,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/__init__.py index 41ec6d71ff7f..a6bfaa2de14d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_app_platform_management_client.py index c0648f257f31..c0ba2a79f368 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_app_platform_management_client.py @@ -9,20 +9,32 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import AppPlatformManagementClientConfiguration -from .operations import AppsOperations, BindingsOperations, CertificatesOperations, ConfigServersOperations, CustomDomainsOperations, DeploymentsOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServicesOperations, SkusOperations +from .operations import ( + AppsOperations, + BindingsOperations, + CertificatesOperations, + ConfigServersOperations, + CustomDomainsOperations, + DeploymentsOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServicesOperations, + SkusOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Cloud. :ivar services: ServicesOperations operations @@ -53,10 +65,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib azure.mgmt.appplatform.v2020_11_01_preview.operations.RuntimeVersionsOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.appplatform.v2020_11_01_preview.operations.SkusOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -74,7 +86,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -83,22 +97,21 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -107,7 +120,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_configuration.py index c42f57794590..a49e82b631a9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-11-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop("api_version", "2020-11-01-preview") # type: Literal["2020-11-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_metadata.json b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_metadata.json index 7e9aa5b71924..4a2ed6b02f2b 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_metadata.json +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}, \"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\": [\"AppPlatformManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -109,4 +109,4 @@ "runtime_versions": "RuntimeVersionsOperations", "skus": "SkusOperations" } -} \ No newline at end of file +} diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_vendor.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_vendor.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_version.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_version.py index e7ffc58c0429..92453d8691d9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_version.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.1.0" +VERSION = "6.1.0" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/__init__.py index 44ce4a5043f8..398c48287ad8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._app_platform_management_client import AppPlatformManagementClient -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/_app_platform_management_client.py index 89198b7ef24a..449e5c871c5c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/_app_platform_management_client.py @@ -9,20 +9,32 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import AppPlatformManagementClientConfiguration -from .operations import AppsOperations, BindingsOperations, CertificatesOperations, ConfigServersOperations, CustomDomainsOperations, DeploymentsOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServicesOperations, SkusOperations +from .operations import ( + AppsOperations, + BindingsOperations, + CertificatesOperations, + ConfigServersOperations, + CustomDomainsOperations, + DeploymentsOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServicesOperations, + SkusOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Cloud. :ivar services: ServicesOperations operations @@ -53,10 +65,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib azure.mgmt.appplatform.v2020_11_01_preview.aio.operations.RuntimeVersionsOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.appplatform.v2020_11_01_preview.aio.operations.SkusOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -74,7 +86,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -83,22 +97,21 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -107,7 +120,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/_configuration.py index ceda2426d5f3..2d9188cabde9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-11-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop("api_version", "2020-11-01-preview") # type: Literal["2020-11-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/__init__.py index aa6fe5cd0cfc..a3674f282ddb 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/__init__.py @@ -18,16 +18,22 @@ from ._runtime_versions_operations import RuntimeVersionsOperations from ._skus_operations import SkusOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', + "ServicesOperations", + "ConfigServersOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_apps_operations.py index 070f860b6e5d..7eae6d45202c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_apps_operations.py @@ -6,46 +6,67 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._apps_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_get_resource_upload_url_request, build_list_request, build_update_request_initial, build_validate_domain_request -T = TypeVar('T') +from ...operations._apps_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_get_resource_upload_url_request, + build_list_request, + build_update_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AppsOperations: - """AppsOperations 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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`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_async async def get( @@ -55,102 +76,125 @@ async def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -158,21 +202,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,20 +303,24 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -206,84 +333,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -293,25 +432,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -323,83 +457,108 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -407,18 +566,97 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -426,20 +664,24 @@ async def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -452,104 +694,121 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncIterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AppResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -563,10 +822,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 @@ -576,74 +833,138 @@ 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.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace_async async def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def validate_domain( @@ -651,67 +972,86 @@ async def validate_domain( resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: Union[_models.CustomDomainValidatePayload, IO], **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. :type validate_payload: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainValidatePayload + ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_bindings_operations.py index 76b37e85fda9..280948d43c31 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_bindings_operations.py @@ -6,113 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._bindings_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._bindings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BindingsOperations: - """BindingsOperations 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 BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +141,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -160,21 +197,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +305,27 @@ async def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +338,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +360,76 @@ async def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -301,28 +439,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -334,46 +466,55 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _update_initial( self, @@ -381,39 +522,55 @@ async def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -421,18 +578,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +683,27 @@ async def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +716,21 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +738,105 @@ async def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +850,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 @@ -599,8 +861,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_certificates_operations.py index 623d65bb8da8..c4fc47f8b7e1 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_certificates_operations.py @@ -6,147 +6,184 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class 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.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.aio.AppPlatformManagementClient`'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_async async def get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(certificate_resource, 'CertificateResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -154,21 +191,101 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -176,21 +293,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CertificateResource"]: + ) -> AsyncLROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type certificate_resource: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource + ~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -203,84 +324,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -290,25 +423,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -320,98 +448,118 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -425,10 +573,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 @@ -438,8 +584,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_config_servers_operations.py index cde7409fb45b..2a96eb03aae3 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_config_servers_operations.py @@ -6,139 +6,174 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._config_servers_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial, build_validate_request_initial -T = TypeVar('T') +from ...operations._config_servers_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConfigServersOperations: - """ConfigServersOperations 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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,37 +181,115 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,86 +302,110 @@ async def begin_update_put( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -276,37 +413,115 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -319,86 +534,110 @@ async def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_settings, 'ConfigServerSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -406,37 +645,115 @@ async def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerSettings + ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -449,47 +766,54 @@ async def begin_validate( or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = await self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_custom_domains_operations.py index 342334a95ff4..fe9794911911 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_custom_domains_operations.py @@ -6,113 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._custom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CustomDomainsOperations: - """CustomDomainsOperations 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 CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +141,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -160,21 +197,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +305,27 @@ async def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +338,21 @@ async def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +360,76 @@ async def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -301,28 +439,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -334,46 +466,55 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _update_initial( self, @@ -381,39 +522,55 @@ async def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -421,18 +578,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +683,27 @@ async def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +716,21 @@ async def begin_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +738,106 @@ async def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +851,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 @@ -599,8 +862,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_deployments_operations.py index 8d6040476800..11db407dfc69 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_deployments_operations.py @@ -6,113 +6,139 @@ # Code generated 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, List, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._deployments_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_log_file_url_request, build_get_request, build_list_for_cluster_request, build_list_request, build_restart_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._deployments_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_log_file_url_request, + build_get_request, + build_list_for_cluster_request, + build_list_request, + build_restart_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeploymentsOperations: - """DeploymentsOperations 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 DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +146,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -160,21 +202,107 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,23 +311,27 @@ async def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -212,19 +344,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -232,67 +366,76 @@ async def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -302,28 +445,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -335,46 +472,55 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _update_initial( self, @@ -382,39 +528,55 @@ async def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -422,18 +584,104 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -442,23 +690,27 @@ async def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -471,19 +723,21 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -491,32 +745,38 @@ async def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -526,60 +786,72 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + ) -> AsyncIterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -593,10 +865,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 @@ -606,69 +876,76 @@ 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -682,10 +959,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 @@ -695,46 +970,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -744,28 +1020,22 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -777,81 +1047,93 @@ async def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -861,28 +1143,22 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -894,81 +1170,93 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore async def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -978,28 +1266,22 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async - async def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1011,98 +1293,110 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async async def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1111,12 +1405,11 @@ async def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_monitoring_settings_operations.py index 16602bed5ecb..c5be1b0155f1 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_monitoring_settings_operations.py @@ -6,139 +6,175 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._monitoring_settings_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial -T = TypeVar('T') +from ...operations._monitoring_settings_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MonitoringSettingsOperations: - """MonitoringSettingsOperations 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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,37 +182,115 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,86 +303,110 @@ async def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -276,37 +414,115 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -319,47 +535,55 @@ async def begin_update_patch( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_operations.py index bf7f85fc01b7..5d3e1eefbad5 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_operations.py @@ -6,82 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.aio.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.appplatform.v2020_11_01_preview.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,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 @@ -108,8 +134,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_runtime_versions_operations.py index 63a48bbde4d3..48897dd6f90d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_runtime_versions_operations.py @@ -6,88 +6,104 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import 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._runtime_versions_operations import build_list_runtime_versions_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RuntimeVersionsOperations: - """RuntimeVersionsOperations 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 RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + async def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_services_operations.py index 21ec27a3598d..d362213fe548 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_services_operations.py @@ -6,141 +6,180 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._services_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_disable_test_endpoint_request, build_enable_test_endpoint_request, build_get_request, build_list_by_subscription_request, build_list_request, build_list_test_keys_request, build_regenerate_test_key_request, build_update_request_initial -T = TypeVar('T') +from ...operations._services_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_disable_test_endpoint_request, + build_enable_test_endpoint_request, + build_get_request, + build_list_by_subscription_request, + build_list_request, + build_list_test_keys_request, + build_regenerate_test_key_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ServicesOperations: - """ServicesOperations 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 ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -148,39 +187,43 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -193,81 +236,163 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] + :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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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 [202, 204]: @@ -277,22 +402,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -304,80 +423,101 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -385,36 +525,40 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -427,220 +571,380 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] + :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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + async def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2020_11_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace_async async def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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', "2020-11-01-preview") # 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -650,170 +954,247 @@ async def disable_test_endpoint( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace_async async def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2020_11_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] - _json = self._serialize.body(availability_parameters, 'NameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -827,10 +1208,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 @@ -840,58 +1219,68 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -905,10 +1294,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 @@ -918,8 +1305,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_skus_operations.py index 6c5411a3e6d7..c4d38adb3d44 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/aio/operations/_skus_operations.py @@ -6,85 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SkusOperations: - """SkusOperations 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 SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) + :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -98,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 @@ -111,8 +135,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/__init__.py index 97492b478eeb..bd90a03b4ac7 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/__init__.py @@ -76,112 +76,114 @@ from ._models_py3 import TrackedResource from ._models_py3 import UserSourceInfo - -from ._app_platform_management_client_enums import ( - ActionType, - AppResourceProvisioningState, - ConfigServerState, - DeploymentResourceProvisioningState, - DeploymentResourceStatus, - ManagedIdentityType, - MonitoringSettingState, - ProvisioningState, - ResourceSkuRestrictionsReasonCode, - ResourceSkuRestrictionsType, - RuntimeVersion, - SkuScaleType, - SupportedRuntimePlatform, - SupportedRuntimeValue, - TestKeyType, - TrafficDirection, - UserSourceType, -) +from ._app_platform_management_client_enums import ActionType +from ._app_platform_management_client_enums import AppResourceProvisioningState +from ._app_platform_management_client_enums import ConfigServerState +from ._app_platform_management_client_enums import DeploymentResourceProvisioningState +from ._app_platform_management_client_enums import DeploymentResourceStatus +from ._app_platform_management_client_enums import ManagedIdentityType +from ._app_platform_management_client_enums import MonitoringSettingState +from ._app_platform_management_client_enums import ProvisioningState +from ._app_platform_management_client_enums import ResourceSkuRestrictionsReasonCode +from ._app_platform_management_client_enums import ResourceSkuRestrictionsType +from ._app_platform_management_client_enums import RuntimeVersion +from ._app_platform_management_client_enums import SkuScaleType +from ._app_platform_management_client_enums import SupportedRuntimePlatform +from ._app_platform_management_client_enums import SupportedRuntimeValue +from ._app_platform_management_client_enums import TestKeyType +from ._app_platform_management_client_enums import TrafficDirection +from ._app_platform_management_client_enums import UserSourceType +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__ = [ - 'AppResource', - 'AppResourceCollection', - 'AppResourceProperties', - 'ApplicationInsightsAgentVersions', - 'AvailableOperations', - 'AvailableRuntimeVersions', - 'BindingResource', - 'BindingResourceCollection', - 'BindingResourceProperties', - 'CertificateProperties', - 'CertificateResource', - 'CertificateResourceCollection', - 'CloudErrorBody', - 'ClusterResourceProperties', - 'ConfigServerGitProperty', - 'ConfigServerProperties', - 'ConfigServerResource', - 'ConfigServerSettings', - 'ConfigServerSettingsErrorRecord', - 'ConfigServerSettingsValidateResult', - 'CustomDomainProperties', - 'CustomDomainResource', - 'CustomDomainResourceCollection', - 'CustomDomainValidatePayload', - 'CustomDomainValidateResult', - 'DeploymentInstance', - 'DeploymentResource', - 'DeploymentResourceCollection', - 'DeploymentResourceProperties', - 'DeploymentSettings', - 'Error', - 'GitPatternRepository', - 'LogFileUrlResponse', - 'LogSpecification', - 'ManagedIdentityProperties', - 'MetricDimension', - 'MetricSpecification', - 'MonitoringSettingProperties', - 'MonitoringSettingResource', - 'NameAvailability', - 'NameAvailabilityParameters', - 'NetworkProfile', - 'NetworkProfileOutboundIPs', - 'OperationDetail', - 'OperationDisplay', - 'OperationProperties', - 'PersistentDisk', - 'ProxyResource', - 'RegenerateTestKeyRequestPayload', - 'RequiredTraffic', - 'Resource', - 'ResourceSku', - 'ResourceSkuCapabilities', - 'ResourceSkuCollection', - 'ResourceSkuLocationInfo', - 'ResourceSkuRestrictionInfo', - 'ResourceSkuRestrictions', - 'ResourceSkuZoneDetails', - 'ResourceUploadDefinition', - 'ServiceResource', - 'ServiceResourceList', - 'ServiceSpecification', - 'Sku', - 'SkuCapacity', - 'SupportedRuntimeVersion', - 'TemporaryDisk', - 'TestKeys', - 'TrackedResource', - 'UserSourceInfo', - 'ActionType', - 'AppResourceProvisioningState', - 'ConfigServerState', - 'DeploymentResourceProvisioningState', - 'DeploymentResourceStatus', - 'ManagedIdentityType', - 'MonitoringSettingState', - 'ProvisioningState', - 'ResourceSkuRestrictionsReasonCode', - 'ResourceSkuRestrictionsType', - 'RuntimeVersion', - 'SkuScaleType', - 'SupportedRuntimePlatform', - 'SupportedRuntimeValue', - 'TestKeyType', - 'TrafficDirection', - 'UserSourceType', + "AppResource", + "AppResourceCollection", + "AppResourceProperties", + "ApplicationInsightsAgentVersions", + "AvailableOperations", + "AvailableRuntimeVersions", + "BindingResource", + "BindingResourceCollection", + "BindingResourceProperties", + "CertificateProperties", + "CertificateResource", + "CertificateResourceCollection", + "CloudErrorBody", + "ClusterResourceProperties", + "ConfigServerGitProperty", + "ConfigServerProperties", + "ConfigServerResource", + "ConfigServerSettings", + "ConfigServerSettingsErrorRecord", + "ConfigServerSettingsValidateResult", + "CustomDomainProperties", + "CustomDomainResource", + "CustomDomainResourceCollection", + "CustomDomainValidatePayload", + "CustomDomainValidateResult", + "DeploymentInstance", + "DeploymentResource", + "DeploymentResourceCollection", + "DeploymentResourceProperties", + "DeploymentSettings", + "Error", + "GitPatternRepository", + "LogFileUrlResponse", + "LogSpecification", + "ManagedIdentityProperties", + "MetricDimension", + "MetricSpecification", + "MonitoringSettingProperties", + "MonitoringSettingResource", + "NameAvailability", + "NameAvailabilityParameters", + "NetworkProfile", + "NetworkProfileOutboundIPs", + "OperationDetail", + "OperationDisplay", + "OperationProperties", + "PersistentDisk", + "ProxyResource", + "RegenerateTestKeyRequestPayload", + "RequiredTraffic", + "Resource", + "ResourceSku", + "ResourceSkuCapabilities", + "ResourceSkuCollection", + "ResourceSkuLocationInfo", + "ResourceSkuRestrictionInfo", + "ResourceSkuRestrictions", + "ResourceSkuZoneDetails", + "ResourceUploadDefinition", + "ServiceResource", + "ServiceResourceList", + "ServiceSpecification", + "Sku", + "SkuCapacity", + "SupportedRuntimeVersion", + "TemporaryDisk", + "TestKeys", + "TrackedResource", + "UserSourceInfo", + "ActionType", + "AppResourceProvisioningState", + "ConfigServerState", + "DeploymentResourceProvisioningState", + "DeploymentResourceStatus", + "ManagedIdentityType", + "MonitoringSettingState", + "ProvisioningState", + "ResourceSkuRestrictionsReasonCode", + "ResourceSkuRestrictionsType", + "RuntimeVersion", + "SkuScaleType", + "SupportedRuntimePlatform", + "SupportedRuntimeValue", + "TestKeyType", + "TrafficDirection", + "UserSourceType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/_app_platform_management_client_enums.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/_app_platform_management_client_enums.py index 483260921151..878e2ebf3d42 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/_app_platform_management_client_enums.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/_app_platform_management_client_enums.py @@ -7,28 +7,26 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - """ +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" INTERNAL = "Internal" -class AppResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the App - """ + +class AppResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the App.""" SUCCEEDED = "Succeeded" FAILED = "Failed" CREATING = "Creating" UPDATING = "Updating" -class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the config server. - """ + +class ConfigServerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the config server.""" NOT_AVAILABLE = "NotAvailable" DELETED = "Deleted" @@ -36,18 +34,18 @@ class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class DeploymentResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Deployment - """ + +class DeploymentResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Deployment.""" CREATING = "Creating" UPDATING = "Updating" SUCCEEDED = "Succeeded" FAILED = "Failed" -class DeploymentResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of the Deployment - """ + +class DeploymentResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the Deployment.""" UNKNOWN = "Unknown" STOPPED = "Stopped" @@ -57,27 +55,27 @@ class DeploymentResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum UPGRADING = "Upgrading" COMPILING = "Compiling" -class ManagedIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the managed identity - """ + +class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the managed identity.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class MonitoringSettingState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Monitoring Setting. - """ + +class MonitoringSettingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Monitoring Setting.""" NOT_AVAILABLE = "NotAvailable" FAILED = "Failed" SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Service - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Service.""" CREATING = "Creating" UPDATING = "Updating" @@ -89,69 +87,70 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MOVED = "Moved" MOVE_FAILED = "MoveFailed" -class ResourceSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription' + 'NotAvailableForSubscription'. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ResourceSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets the type of restrictions. Possible values include: 'Location', 'Zone' - """ + +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the type of restrictions. Possible values include: 'Location', 'Zone'.""" LOCATION = "Location" ZONE = "Zone" -class RuntimeVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Runtime version - """ + +class RuntimeVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Runtime version.""" JAVA8 = "Java_8" JAVA11 = "Java_11" NET_CORE31 = "NetCore_31" -class SkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets or sets the type of the scale. - """ + +class SkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type of the scale.""" NONE = "None" MANUAL = "Manual" AUTOMATIC = "Automatic" -class SupportedRuntimePlatform(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The platform of this runtime version (possible values: "Java" or ".NET"). - """ + +class SupportedRuntimePlatform(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The platform of this runtime version (possible values: "Java" or ".NET").""" JAVA = "Java" _NET_CORE = ".NET Core" -class SupportedRuntimeValue(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The raw value which could be passed to deployment CRUD operations. - """ + +class SupportedRuntimeValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The raw value which could be passed to deployment CRUD operations.""" JAVA8 = "Java_8" JAVA11 = "Java_11" NET_CORE31 = "NetCore_31" -class TestKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the test key - """ + +class TestKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the test key.""" PRIMARY = "Primary" SECONDARY = "Secondary" -class TrafficDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The direction of required traffic - """ + +class TrafficDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The direction of required traffic.""" INBOUND = "Inbound" OUTBOUND = "Outbound" -class UserSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the source uploaded - """ + +class UserSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the source uploaded.""" JAR = "Jar" NET_CORE_ZIP = "NetCoreZip" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/_models_py3.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/_models_py3.py index b933174dc563..d74d8f57dee2 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/_models_py3.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._app_platform_management_client_enums import * +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ApplicationInsightsAgentVersions(msrest.serialization.Model): + +class ApplicationInsightsAgentVersions(_serialization.Model): """Application Insights agent versions properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -23,24 +33,20 @@ class ApplicationInsightsAgentVersions(msrest.serialization.Model): """ _validation = { - 'java': {'readonly': True}, + "java": {"readonly": True}, } _attribute_map = { - 'java': {'key': 'java', 'type': 'str'}, + "java": {"key": "java", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApplicationInsightsAgentVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.java = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The core properties of ARM resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -54,24 +60,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -91,24 +93,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class AppResource(ProxyResource): @@ -131,25 +129,25 @@ class AppResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'AppResourceProperties'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentityProperties'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "AppResourceProperties"}, + "identity": {"key": "identity", "type": "ManagedIdentityProperties"}, + "location": {"key": "location", "type": "str"}, } def __init__( self, *, - properties: Optional["AppResourceProperties"] = None, - identity: Optional["ManagedIdentityProperties"] = None, + properties: Optional["_models.AppResourceProperties"] = None, + identity: Optional["_models.ManagedIdentityProperties"] = None, location: Optional[str] = None, **kwargs ): @@ -163,13 +161,13 @@ def __init__( resource. :paramtype location: str """ - super(AppResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.identity = identity self.location = location -class AppResourceCollection(msrest.serialization.Model): +class AppResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of App resources. @@ -180,16 +178,12 @@ class AppResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AppResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AppResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["AppResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.AppResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of App resources. @@ -198,12 +192,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(AppResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class AppResourceProperties(msrest.serialization.Model): +class AppResourceProperties(_serialization.Model): """App resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -212,8 +206,8 @@ class AppResourceProperties(msrest.serialization.Model): :vartype public: bool :ivar url: URL of the App. :vartype url: str - :ivar provisioning_state: Provisioning state of the App. Possible values include: "Succeeded", - "Failed", "Creating", "Updating". + :ivar provisioning_state: Provisioning state of the App. Known values are: "Succeeded", + "Failed", "Creating", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResourceProvisioningState :ivar active_deployment_name: Name of the active deployment of the App. @@ -233,22 +227,22 @@ class AppResourceProperties(msrest.serialization.Model): """ _validation = { - 'url': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'created_time': {'readonly': True}, + "url": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "created_time": {"readonly": True}, } _attribute_map = { - 'public': {'key': 'public', 'type': 'bool'}, - 'url': {'key': 'url', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'active_deployment_name': {'key': 'activeDeploymentName', 'type': 'str'}, - 'fqdn': {'key': 'fqdn', 'type': 'str'}, - 'https_only': {'key': 'httpsOnly', 'type': 'bool'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'temporary_disk': {'key': 'temporaryDisk', 'type': 'TemporaryDisk'}, - 'persistent_disk': {'key': 'persistentDisk', 'type': 'PersistentDisk'}, - 'enable_end_to_end_tls': {'key': 'enableEndToEndTLS', 'type': 'bool'}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "active_deployment_name": {"key": "activeDeploymentName", "type": "str"}, + "fqdn": {"key": "fqdn", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "temporary_disk": {"key": "temporaryDisk", "type": "TemporaryDisk"}, + "persistent_disk": {"key": "persistentDisk", "type": "PersistentDisk"}, + "enable_end_to_end_tls": {"key": "enableEndToEndTLS", "type": "bool"}, } def __init__( @@ -257,10 +251,10 @@ def __init__( public: Optional[bool] = None, active_deployment_name: Optional[str] = None, fqdn: Optional[str] = None, - https_only: Optional[bool] = False, - temporary_disk: Optional["TemporaryDisk"] = None, - persistent_disk: Optional["PersistentDisk"] = None, - enable_end_to_end_tls: Optional[bool] = False, + https_only: bool = False, + temporary_disk: Optional["_models.TemporaryDisk"] = None, + persistent_disk: Optional["_models.PersistentDisk"] = None, + enable_end_to_end_tls: bool = False, **kwargs ): """ @@ -279,7 +273,7 @@ def __init__( :keyword enable_end_to_end_tls: Indicate if end to end TLS is enabled. :paramtype enable_end_to_end_tls: bool """ - super(AppResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.public = public self.url = None self.provisioning_state = None @@ -292,7 +286,7 @@ def __init__( self.enable_end_to_end_tls = enable_end_to_end_tls -class AvailableOperations(msrest.serialization.Model): +class AvailableOperations(_serialization.Model): """Available operations of the service. :ivar value: Collection of available operation details. @@ -303,16 +297,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. @@ -321,12 +311,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 AvailableRuntimeVersions(msrest.serialization.Model): +class AvailableRuntimeVersions(_serialization.Model): """AvailableRuntimeVersions. Variables are only populated by the server, and will be ignored when sending a request. @@ -337,20 +327,16 @@ class AvailableRuntimeVersions(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedRuntimeVersion]'}, + "value": {"key": "value", "type": "[SupportedRuntimeVersion]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AvailableRuntimeVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -371,34 +357,29 @@ class BindingResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'BindingResourceProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "BindingResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["BindingResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BindingResourceProperties"] = None, **kwargs): """ :keyword properties: Properties of the Binding resource. :paramtype properties: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResourceProperties """ - super(BindingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BindingResourceCollection(msrest.serialization.Model): +class BindingResourceCollection(_serialization.Model): """Object that includes an array of Binding resources and a possible link for next set. :ivar value: Collection of Binding resources. @@ -409,16 +390,12 @@ class BindingResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BindingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BindingResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BindingResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Binding resources. @@ -427,12 +404,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BindingResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BindingResourceProperties(msrest.serialization.Model): +class BindingResourceProperties(_serialization.Model): """Binding resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -446,7 +423,7 @@ class BindingResourceProperties(msrest.serialization.Model): :ivar key: The key of the bound resource. :vartype key: str :ivar binding_parameters: Binding parameters of the Binding resource. - :vartype binding_parameters: dict[str, any] + :vartype binding_parameters: dict[str, JSON] :ivar generated_properties: The generated Spring Boot property file for this binding. The secret will be deducted. :vartype generated_properties: str @@ -457,22 +434,22 @@ class BindingResourceProperties(msrest.serialization.Model): """ _validation = { - 'resource_name': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'generated_properties': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, + "resource_name": {"readonly": True}, + "resource_type": {"readonly": True}, + "generated_properties": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, } _attribute_map = { - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'binding_parameters': {'key': 'bindingParameters', 'type': '{object}'}, - 'generated_properties': {'key': 'generatedProperties', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'str'}, - 'updated_at': {'key': 'updatedAt', 'type': 'str'}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "binding_parameters": {"key": "bindingParameters", "type": "{object}"}, + "generated_properties": {"key": "generatedProperties", "type": "str"}, + "created_at": {"key": "createdAt", "type": "str"}, + "updated_at": {"key": "updatedAt", "type": "str"}, } def __init__( @@ -480,7 +457,7 @@ def __init__( *, resource_id: Optional[str] = None, key: Optional[str] = None, - binding_parameters: Optional[Dict[str, Any]] = None, + binding_parameters: Optional[Dict[str, JSON]] = None, **kwargs ): """ @@ -489,9 +466,9 @@ def __init__( :keyword key: The key of the bound resource. :paramtype key: str :keyword binding_parameters: Binding parameters of the Binding resource. - :paramtype binding_parameters: dict[str, any] + :paramtype binding_parameters: dict[str, JSON] """ - super(BindingResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_name = None self.resource_type = None self.resource_id = resource_id @@ -502,7 +479,7 @@ def __init__( self.updated_at = None -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """Certificate resource payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -511,9 +488,9 @@ class CertificateProperties(msrest.serialization.Model): :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str - :ivar vault_uri: Required. The vault uri of user key vault. + :ivar vault_uri: The vault uri of user key vault. Required. :vartype vault_uri: str - :ivar key_vault_cert_name: Required. The certificate name of key vault. + :ivar key_vault_cert_name: The certificate name of key vault. Required. :vartype key_vault_cert_name: str :ivar cert_version: The certificate version of key vault. :vartype cert_version: str @@ -532,47 +509,40 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'thumbprint': {'readonly': True}, - 'vault_uri': {'required': True}, - 'key_vault_cert_name': {'required': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, - } - - _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'vault_uri': {'key': 'vaultUri', 'type': 'str'}, - 'key_vault_cert_name': {'key': 'keyVaultCertName', 'type': 'str'}, - 'cert_version': {'key': 'certVersion', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, + "thumbprint": {"readonly": True}, + "vault_uri": {"required": True}, + "key_vault_cert_name": {"required": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, } - def __init__( - self, - *, - vault_uri: str, - key_vault_cert_name: str, - cert_version: Optional[str] = None, - **kwargs - ): + _attribute_map = { + "thumbprint": {"key": "thumbprint", "type": "str"}, + "vault_uri": {"key": "vaultUri", "type": "str"}, + "key_vault_cert_name": {"key": "keyVaultCertName", "type": "str"}, + "cert_version": {"key": "certVersion", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + } + + def __init__(self, *, vault_uri: str, key_vault_cert_name: str, cert_version: Optional[str] = None, **kwargs): """ - :keyword vault_uri: Required. The vault uri of user key vault. + :keyword vault_uri: The vault uri of user key vault. Required. :paramtype vault_uri: str - :keyword key_vault_cert_name: Required. The certificate name of key vault. + :keyword key_vault_cert_name: The certificate name of key vault. Required. :paramtype key_vault_cert_name: str :keyword cert_version: The certificate version of key vault. :paramtype cert_version: str """ - super(CertificateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = None self.vault_uri = vault_uri self.key_vault_cert_name = key_vault_cert_name @@ -601,33 +571,28 @@ class CertificateResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "CertificateProperties"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: Properties of the certificate resource payload. :paramtype properties: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateProperties """ - super(CertificateResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CertificateResourceCollection(msrest.serialization.Model): +class CertificateResourceCollection(_serialization.Model): """Collection compose of certificate resources list and a possible link for next page. :ivar value: The certificate resources list. @@ -637,16 +602,12 @@ class CertificateResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CertificateResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CertificateResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CertificateResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The certificate resources list. @@ -654,12 +615,12 @@ def __init__( :keyword next_link: The link to next page of certificate list. :paramtype next_link: str """ - super(CertificateResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -676,10 +637,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -688,7 +649,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -704,21 +665,20 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.appplatform.v2020_11_01_preview.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class ClusterResourceProperties(msrest.serialization.Model): +class ClusterResourceProperties(_serialization.Model): """Service properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Provisioning state of the Service. Possible values include: - "Creating", "Updating", "Deleting", "Deleted", "Succeeded", "Failed", "Moving", "Moved", - "MoveFailed". + :ivar provisioning_state: Provisioning state of the Service. Known values are: "Creating", + "Updating", "Deleting", "Deleted", "Succeeded", "Failed", "Moving", "Moved", and "MoveFailed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.ProvisioningState :ivar network_profile: Network profile of the Service. @@ -730,36 +690,31 @@ class ClusterResourceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'version': {'readonly': True}, - 'service_id': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "service_id": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'network_profile': {'key': 'networkProfile', 'type': 'NetworkProfile'}, - 'version': {'key': 'version', 'type': 'int'}, - 'service_id': {'key': 'serviceId', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "network_profile": {"key": "networkProfile", "type": "NetworkProfile"}, + "version": {"key": "version", "type": "int"}, + "service_id": {"key": "serviceId", "type": "str"}, } - def __init__( - self, - *, - network_profile: Optional["NetworkProfile"] = None, - **kwargs - ): + def __init__(self, *, network_profile: Optional["_models.NetworkProfile"] = None, **kwargs): """ :keyword network_profile: Network profile of the Service. :paramtype network_profile: ~azure.mgmt.appplatform.v2020_11_01_preview.models.NetworkProfile """ - super(ClusterResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.network_profile = network_profile self.version = None self.service_id = None -class ConfigServerGitProperty(msrest.serialization.Model): +class ConfigServerGitProperty(_serialization.Model): """Property of git. All required parameters must be populated in order to send to Azure. @@ -767,7 +722,7 @@ class ConfigServerGitProperty(msrest.serialization.Model): :ivar repositories: Repositories of git. :vartype repositories: list[~azure.mgmt.appplatform.v2020_11_01_preview.models.GitPatternRepository] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -788,27 +743,27 @@ class ConfigServerGitProperty(msrest.serialization.Model): """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'repositories': {'key': 'repositories', 'type': '[GitPatternRepository]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "repositories": {"key": "repositories", "type": "[GitPatternRepository]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( self, *, uri: str, - repositories: Optional[List["GitPatternRepository"]] = None, + repositories: Optional[List["_models.GitPatternRepository"]] = None, label: Optional[str] = None, search_paths: Optional[List[str]] = None, username: Optional[str] = None, @@ -823,7 +778,7 @@ def __init__( :keyword repositories: Repositories of git. :paramtype repositories: list[~azure.mgmt.appplatform.v2020_11_01_preview.models.GitPatternRepository] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -842,7 +797,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(ConfigServerGitProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.repositories = repositories self.uri = uri self.label = label @@ -855,13 +810,13 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ConfigServerProperties(msrest.serialization.Model): +class ConfigServerProperties(_serialization.Model): """Config server git properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the config server. Possible values include: "NotAvailable", - "Deleted", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the config server. Known values are: "NotAvailable", + "Deleted", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerState :ivar error: Error when apply config server settings. @@ -871,20 +826,20 @@ class ConfigServerProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'config_server': {'key': 'configServer', 'type': 'ConfigServerSettings'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "config_server": {"key": "configServer", "type": "ConfigServerSettings"}, } def __init__( self, *, - error: Optional["Error"] = None, - config_server: Optional["ConfigServerSettings"] = None, + error: Optional["_models.Error"] = None, + config_server: Optional["_models.ConfigServerSettings"] = None, **kwargs ): """ @@ -894,7 +849,7 @@ def __init__( :paramtype config_server: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerSettings """ - super(ConfigServerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.config_server = config_server @@ -916,34 +871,29 @@ class ConfigServerResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ConfigServerProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ConfigServerProperties"}, } - def __init__( - self, - *, - properties: Optional["ConfigServerProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ConfigServerProperties"] = None, **kwargs): """ :keyword properties: Properties of the Config Server resource. :paramtype properties: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerProperties """ - super(ConfigServerResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ConfigServerSettings(msrest.serialization.Model): +class ConfigServerSettings(_serialization.Model): """The settings of config server. :ivar git_property: Property of git environment. @@ -952,25 +902,20 @@ class ConfigServerSettings(msrest.serialization.Model): """ _attribute_map = { - 'git_property': {'key': 'gitProperty', 'type': 'ConfigServerGitProperty'}, + "git_property": {"key": "gitProperty", "type": "ConfigServerGitProperty"}, } - def __init__( - self, - *, - git_property: Optional["ConfigServerGitProperty"] = None, - **kwargs - ): + def __init__(self, *, git_property: Optional["_models.ConfigServerGitProperty"] = None, **kwargs): """ :keyword git_property: Property of git environment. :paramtype git_property: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerGitProperty """ - super(ConfigServerSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property = git_property -class ConfigServerSettingsErrorRecord(msrest.serialization.Model): +class ConfigServerSettingsErrorRecord(_serialization.Model): """Error record of the config server settings. :ivar name: The name of the config server settings error record. @@ -982,18 +927,13 @@ class ConfigServerSettingsErrorRecord(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'messages': {'key': 'messages', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, } def __init__( - self, - *, - name: Optional[str] = None, - uri: Optional[str] = None, - messages: Optional[List[str]] = None, - **kwargs + self, *, name: Optional[str] = None, uri: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs ): """ :keyword name: The name of the config server settings error record. @@ -1003,13 +943,13 @@ def __init__( :keyword messages: The detail error messages of the record. :paramtype messages: list[str] """ - super(ConfigServerSettingsErrorRecord, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.uri = uri self.messages = messages -class ConfigServerSettingsValidateResult(msrest.serialization.Model): +class ConfigServerSettingsValidateResult(_serialization.Model): """Validation result for config server settings. :ivar is_valid: Indicate if the config server settings are valid. @@ -1020,15 +960,15 @@ class ConfigServerSettingsValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'details': {'key': 'details', 'type': '[ConfigServerSettingsErrorRecord]'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "details": {"key": "details", "type": "[ConfigServerSettingsErrorRecord]"}, } def __init__( self, *, is_valid: Optional[bool] = None, - details: Optional[List["ConfigServerSettingsErrorRecord"]] = None, + details: Optional[List["_models.ConfigServerSettingsErrorRecord"]] = None, **kwargs ): """ @@ -1038,12 +978,12 @@ def __init__( :paramtype details: list[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerSettingsErrorRecord] """ - super(ConfigServerSettingsValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.details = details -class CustomDomainProperties(msrest.serialization.Model): +class CustomDomainProperties(_serialization.Model): """Custom domain of app resource payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1057,29 +997,23 @@ class CustomDomainProperties(msrest.serialization.Model): """ _validation = { - 'app_name': {'readonly': True}, + "app_name": {"readonly": True}, } _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'app_name': {'key': 'appName', 'type': 'str'}, - 'cert_name': {'key': 'certName', 'type': 'str'}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "app_name": {"key": "appName", "type": "str"}, + "cert_name": {"key": "certName", "type": "str"}, } - def __init__( - self, - *, - thumbprint: Optional[str] = None, - cert_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, thumbprint: Optional[str] = None, cert_name: Optional[str] = None, **kwargs): """ :keyword thumbprint: The thumbprint of bound certificate. :paramtype thumbprint: str :keyword cert_name: The bound certificate name of domain. :paramtype cert_name: str """ - super(CustomDomainProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = thumbprint self.app_name = None self.cert_name = cert_name @@ -1101,34 +1035,29 @@ class CustomDomainResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'CustomDomainProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "CustomDomainProperties"}, } - def __init__( - self, - *, - properties: Optional["CustomDomainProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CustomDomainProperties"] = None, **kwargs): """ :keyword properties: Properties of the custom domain resource. :paramtype properties: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainProperties """ - super(CustomDomainResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CustomDomainResourceCollection(msrest.serialization.Model): +class CustomDomainResourceCollection(_serialization.Model): """Collection compose of a custom domain resources list and a possible link for next page. :ivar value: The custom domain resources list. @@ -1138,16 +1067,12 @@ class CustomDomainResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CustomDomainResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CustomDomainResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The custom domain resources list. @@ -1155,43 +1080,38 @@ def __init__( :keyword next_link: The link to next page of custom domain list. :paramtype next_link: str """ - super(CustomDomainResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CustomDomainValidatePayload(msrest.serialization.Model): +class CustomDomainValidatePayload(_serialization.Model): """Custom domain validate payload. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name to be validated. + :ivar name: Name to be validated. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Name to be validated. + :keyword name: Name to be validated. Required. :paramtype name: str """ - super(CustomDomainValidatePayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CustomDomainValidateResult(msrest.serialization.Model): +class CustomDomainValidateResult(_serialization.Model): """Validation result for custom domain. :ivar is_valid: Indicates if domain name is valid. @@ -1201,29 +1121,23 @@ class CustomDomainValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'message': {'key': 'message', 'type': 'str'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - is_valid: Optional[bool] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, is_valid: Optional[bool] = None, message: Optional[str] = None, **kwargs): """ :keyword is_valid: Indicates if domain name is valid. :paramtype is_valid: bool :keyword message: Message of why domain name is invalid. :paramtype message: str """ - super(CustomDomainValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.message = message -class DeploymentInstance(msrest.serialization.Model): +class DeploymentInstance(_serialization.Model): """Deployment instance payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1241,28 +1155,24 @@ class DeploymentInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, - 'reason': {'readonly': True}, - 'discovery_status': {'readonly': True}, - 'start_time': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, + "reason": {"readonly": True}, + "discovery_status": {"readonly": True}, + "start_time": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'discovery_status': {'key': 'discoveryStatus', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "discovery_status": {"key": "discoveryStatus", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None self.reason = None @@ -1289,24 +1199,24 @@ class DeploymentResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( self, *, - properties: Optional["DeploymentResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.DeploymentResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -1316,12 +1226,12 @@ def __init__( :keyword sku: Sku of the Deployment resource. :paramtype sku: ~azure.mgmt.appplatform.v2020_11_01_preview.models.Sku """ - super(DeploymentResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.sku = sku -class DeploymentResourceCollection(msrest.serialization.Model): +class DeploymentResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of Deployment resources. @@ -1332,16 +1242,12 @@ class DeploymentResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["DeploymentResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.DeploymentResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Deployment resources. @@ -1350,12 +1256,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(DeploymentResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class DeploymentResourceProperties(msrest.serialization.Model): +class DeploymentResourceProperties(_serialization.Model): """Deployment resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1367,12 +1273,12 @@ class DeploymentResourceProperties(msrest.serialization.Model): :ivar deployment_settings: Deployment settings of the Deployment. :vartype deployment_settings: ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentSettings - :ivar provisioning_state: Provisioning state of the Deployment. Possible values include: - "Creating", "Updating", "Succeeded", "Failed". + :ivar provisioning_state: Provisioning state of the Deployment. Known values are: "Creating", + "Updating", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResourceProvisioningState - :ivar status: Status of the Deployment. Possible values include: "Unknown", "Stopped", - "Running", "Failed", "Allocating", "Upgrading", "Compiling". + :ivar status: Status of the Deployment. Known values are: "Unknown", "Stopped", "Running", + "Failed", "Allocating", "Upgrading", and "Compiling". :vartype status: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResourceStatus :ivar active: Indicates whether the Deployment is active. @@ -1384,30 +1290,30 @@ class DeploymentResourceProperties(msrest.serialization.Model): """ _validation = { - 'app_name': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'active': {'readonly': True}, - 'created_time': {'readonly': True}, - 'instances': {'readonly': True}, + "app_name": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "active": {"readonly": True}, + "created_time": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'UserSourceInfo'}, - 'app_name': {'key': 'appName', 'type': 'str'}, - 'deployment_settings': {'key': 'deploymentSettings', 'type': 'DeploymentSettings'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'active': {'key': 'active', 'type': 'bool'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'instances': {'key': 'instances', 'type': '[DeploymentInstance]'}, + "source": {"key": "source", "type": "UserSourceInfo"}, + "app_name": {"key": "appName", "type": "str"}, + "deployment_settings": {"key": "deploymentSettings", "type": "DeploymentSettings"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "active": {"key": "active", "type": "bool"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "instances": {"key": "instances", "type": "[DeploymentInstance]"}, } def __init__( self, *, - source: Optional["UserSourceInfo"] = None, - deployment_settings: Optional["DeploymentSettings"] = None, + source: Optional["_models.UserSourceInfo"] = None, + deployment_settings: Optional["_models.DeploymentSettings"] = None, **kwargs ): """ @@ -1417,7 +1323,7 @@ def __init__( :paramtype deployment_settings: ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentSettings """ - super(DeploymentResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.app_name = None self.deployment_settings = deployment_settings @@ -1428,7 +1334,7 @@ def __init__( self.instances = None -class DeploymentSettings(msrest.serialization.Model): +class DeploymentSettings(_serialization.Model): """Deployment settings payload. :ivar cpu: Required CPU, basic tier should be 1, standard tier should be in range (1, 4). @@ -1442,30 +1348,30 @@ class DeploymentSettings(msrest.serialization.Model): :vartype net_core_main_entry_path: str :ivar environment_variables: Collection of environment variables. :vartype environment_variables: dict[str, str] - :ivar runtime_version: Runtime version. Possible values include: "Java_8", "Java_11", - "NetCore_31". Default value: "Java_8". + :ivar runtime_version: Runtime version. Known values are: "Java_8", "Java_11", and + "NetCore_31". :vartype runtime_version: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.RuntimeVersion """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'int'}, - 'memory_in_gb': {'key': 'memoryInGB', 'type': 'int'}, - 'jvm_options': {'key': 'jvmOptions', 'type': 'str'}, - 'net_core_main_entry_path': {'key': 'netCoreMainEntryPath', 'type': 'str'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '{str}'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "int"}, + "memory_in_gb": {"key": "memoryInGB", "type": "int"}, + "jvm_options": {"key": "jvmOptions", "type": "str"}, + "net_core_main_entry_path": {"key": "netCoreMainEntryPath", "type": "str"}, + "environment_variables": {"key": "environmentVariables", "type": "{str}"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, } def __init__( self, *, - cpu: Optional[int] = 1, - memory_in_gb: Optional[int] = 1, + cpu: int = 1, + memory_in_gb: int = 1, jvm_options: Optional[str] = None, net_core_main_entry_path: Optional[str] = None, environment_variables: Optional[Dict[str, str]] = None, - runtime_version: Optional[Union[str, "RuntimeVersion"]] = "Java_8", + runtime_version: Union[str, "_models.RuntimeVersion"] = "Java_8", **kwargs ): """ @@ -1480,12 +1386,12 @@ def __init__( :paramtype net_core_main_entry_path: str :keyword environment_variables: Collection of environment variables. :paramtype environment_variables: dict[str, str] - :keyword runtime_version: Runtime version. Possible values include: "Java_8", "Java_11", - "NetCore_31". Default value: "Java_8". + :keyword runtime_version: Runtime version. Known values are: "Java_8", "Java_11", and + "NetCore_31". :paramtype runtime_version: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.RuntimeVersion """ - super(DeploymentSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory_in_gb = memory_in_gb self.jvm_options = jvm_options @@ -1494,7 +1400,7 @@ def __init__( self.runtime_version = runtime_version -class Error(msrest.serialization.Model): +class Error(_serialization.Model): """The error code compose of code and message. :ivar code: The code of error. @@ -1504,38 +1410,32 @@ class Error(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: The code of error. :paramtype code: str :keyword message: The message of error. :paramtype message: str """ - super(Error, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class GitPatternRepository(msrest.serialization.Model): +class GitPatternRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes """Git repository property payload. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the repository. + :ivar name: Name of the repository. Required. :vartype name: str :ivar pattern: Collection of pattern of the repository. :vartype pattern: list[str] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -1556,22 +1456,22 @@ class GitPatternRepository(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'uri': {'required': True}, + "name": {"required": True}, + "uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'pattern': {'key': 'pattern', 'type': '[str]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "pattern": {"key": "pattern", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( @@ -1591,11 +1491,11 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of the repository. + :keyword name: Name of the repository. Required. :paramtype name: str :keyword pattern: Collection of pattern of the repository. :paramtype pattern: list[str] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -1614,7 +1514,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(GitPatternRepository, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.pattern = pattern self.uri = uri @@ -1628,38 +1528,33 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class LogFileUrlResponse(msrest.serialization.Model): +class LogFileUrlResponse(_serialization.Model): """Log file URL payload. All required parameters must be populated in order to send to Azure. - :ivar url: Required. URL of the log file. + :ivar url: URL of the log file. Required. :vartype url: str """ _validation = { - 'url': {'required': True}, + "url": {"required": True}, } _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, } - def __init__( - self, - *, - url: str, - **kwargs - ): + def __init__(self, *, url: str, **kwargs): """ - :keyword url: Required. URL of the log file. + :keyword url: URL of the log file. Required. :paramtype url: str """ - super(LogFileUrlResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url -class LogSpecification(msrest.serialization.Model): +class LogSpecification(_serialization.Model): """Specifications of the Log for Azure Monitoring. :ivar name: Name of the log. @@ -1671,9 +1566,9 @@ class LogSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, } def __init__( @@ -1692,17 +1587,17 @@ def __init__( :keyword blob_duration: Blob duration of the log. :paramtype blob_duration: str """ - super(LogSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class ManagedIdentityProperties(msrest.serialization.Model): +class ManagedIdentityProperties(_serialization.Model): """Managed identity properties retrieved from ARM request headers. - :ivar type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.ManagedIdentityType :ivar principal_id: Principal Id. :vartype principal_id: str @@ -1711,35 +1606,35 @@ class ManagedIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ManagedIdentityType"]] = None, + type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs ): """ - :keyword type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.ManagedIdentityType :keyword principal_id: Principal Id. :paramtype principal_id: str :keyword tenant_id: Tenant Id. :paramtype tenant_id: str """ - super(ManagedIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.principal_id = principal_id self.tenant_id = tenant_id -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """Specifications of the Dimension of metrics. :ivar name: Name of the dimension. @@ -1752,9 +1647,9 @@ class MetricDimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -1774,13 +1669,13 @@ def __init__( export scenario. :paramtype to_be_exported_for_shoebox: bool """ - super(MetricDimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes """Specifications of the Metrics for Azure Monitoring. :ivar name: Name of the metric. @@ -1811,17 +1706,17 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "source_mdm_namespace": {"key": "sourceMdmNamespace", "type": "str"}, } def __init__( @@ -1836,7 +1731,7 @@ def __init__( supported_aggregation_types: Optional[List[str]] = None, supported_time_grain_types: Optional[List[str]] = None, fill_gap_with_zero: Optional[bool] = None, - dimensions: Optional[List["MetricDimension"]] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, source_mdm_namespace: Optional[str] = None, **kwargs ): @@ -1867,7 +1762,7 @@ def __init__( :keyword source_mdm_namespace: Name of the MDM namespace. Optional. :paramtype source_mdm_namespace: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1881,13 +1776,13 @@ def __init__( self.source_mdm_namespace = source_mdm_namespace -class MonitoringSettingProperties(msrest.serialization.Model): +class MonitoringSettingProperties(_serialization.Model): """Monitoring Setting properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Monitoring Setting. Possible values include: - "NotAvailable", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the Monitoring Setting. Known values are: "NotAvailable", + "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingState :ivar error: Error when apply Monitoring Setting changes. @@ -1908,27 +1803,27 @@ class MonitoringSettingProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'app_insights_sampling_rate': {'maximum': 100, 'minimum': 0}, + "provisioning_state": {"readonly": True}, + "app_insights_sampling_rate": {"maximum": 100, "minimum": 0}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'trace_enabled': {'key': 'traceEnabled', 'type': 'bool'}, - 'app_insights_instrumentation_key': {'key': 'appInsightsInstrumentationKey', 'type': 'str'}, - 'app_insights_sampling_rate': {'key': 'appInsightsSamplingRate', 'type': 'float'}, - 'app_insights_agent_versions': {'key': 'appInsightsAgentVersions', 'type': 'ApplicationInsightsAgentVersions'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "trace_enabled": {"key": "traceEnabled", "type": "bool"}, + "app_insights_instrumentation_key": {"key": "appInsightsInstrumentationKey", "type": "str"}, + "app_insights_sampling_rate": {"key": "appInsightsSamplingRate", "type": "float"}, + "app_insights_agent_versions": {"key": "appInsightsAgentVersions", "type": "ApplicationInsightsAgentVersions"}, } def __init__( self, *, - error: Optional["Error"] = None, + error: Optional["_models.Error"] = None, trace_enabled: Optional[bool] = None, app_insights_instrumentation_key: Optional[str] = None, app_insights_sampling_rate: Optional[float] = None, - app_insights_agent_versions: Optional["ApplicationInsightsAgentVersions"] = None, + app_insights_agent_versions: Optional["_models.ApplicationInsightsAgentVersions"] = None, **kwargs ): """ @@ -1948,7 +1843,7 @@ def __init__( :paramtype app_insights_agent_versions: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ApplicationInsightsAgentVersions """ - super(MonitoringSettingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.trace_enabled = trace_enabled @@ -1974,34 +1869,29 @@ class MonitoringSettingResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'MonitoringSettingProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "MonitoringSettingProperties"}, } - def __init__( - self, - *, - properties: Optional["MonitoringSettingProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.MonitoringSettingProperties"] = None, **kwargs): """ :keyword properties: Properties of the Monitoring Setting resource. :paramtype properties: ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingProperties """ - super(MonitoringSettingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class NameAvailability(msrest.serialization.Model): +class NameAvailability(_serialization.Model): """Name availability result payload. :ivar name_available: Indicates whether the name is available. @@ -2013,9 +1903,9 @@ class NameAvailability(msrest.serialization.Model): """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } def __init__( @@ -2034,52 +1924,46 @@ def __init__( :keyword message: Message why the name is not available. :paramtype message: str """ - super(NameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class NameAvailabilityParameters(msrest.serialization.Model): +class NameAvailabilityParameters(_serialization.Model): """Name availability parameters payload. All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the resource to check name availability. + :ivar type: Type of the resource to check name availability. Required. :vartype type: str - :ivar name: Required. Name to be checked. + :ivar name: Name to be checked. Required. :vartype name: str """ _validation = { - 'type': {'required': True}, - 'name': {'required': True}, + "type": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - type: str, - name: str, - **kwargs - ): + def __init__(self, *, type: str, name: str, **kwargs): """ - :keyword type: Required. Type of the resource to check name availability. + :keyword type: Type of the resource to check name availability. Required. :paramtype type: str - :keyword name: Required. Name to be checked. + :keyword name: Name to be checked. Required. :paramtype name: str """ - super(NameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class NetworkProfile(msrest.serialization.Model): +class NetworkProfile(_serialization.Model): """Service network profile payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2106,18 +1990,18 @@ class NetworkProfile(msrest.serialization.Model): """ _validation = { - 'outbound_i_ps': {'readonly': True}, - 'required_traffics': {'readonly': True}, + "outbound_i_ps": {"readonly": True}, + "required_traffics": {"readonly": True}, } _attribute_map = { - 'service_runtime_subnet_id': {'key': 'serviceRuntimeSubnetId', 'type': 'str'}, - 'app_subnet_id': {'key': 'appSubnetId', 'type': 'str'}, - 'service_cidr': {'key': 'serviceCidr', 'type': 'str'}, - 'service_runtime_network_resource_group': {'key': 'serviceRuntimeNetworkResourceGroup', 'type': 'str'}, - 'app_network_resource_group': {'key': 'appNetworkResourceGroup', 'type': 'str'}, - 'outbound_i_ps': {'key': 'outboundIPs', 'type': 'NetworkProfileOutboundIPs'}, - 'required_traffics': {'key': 'requiredTraffics', 'type': '[RequiredTraffic]'}, + "service_runtime_subnet_id": {"key": "serviceRuntimeSubnetId", "type": "str"}, + "app_subnet_id": {"key": "appSubnetId", "type": "str"}, + "service_cidr": {"key": "serviceCidr", "type": "str"}, + "service_runtime_network_resource_group": {"key": "serviceRuntimeNetworkResourceGroup", "type": "str"}, + "app_network_resource_group": {"key": "appNetworkResourceGroup", "type": "str"}, + "outbound_i_ps": {"key": "outboundIPs", "type": "NetworkProfileOutboundIPs"}, + "required_traffics": {"key": "requiredTraffics", "type": "[RequiredTraffic]"}, } def __init__( @@ -2146,7 +2030,7 @@ def __init__( Azure Spring Cloud Apps. :paramtype app_network_resource_group: str """ - super(NetworkProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_runtime_subnet_id = service_runtime_subnet_id self.app_subnet_id = app_subnet_id self.service_cidr = service_cidr @@ -2156,7 +2040,7 @@ def __init__( self.required_traffics = None -class NetworkProfileOutboundIPs(msrest.serialization.Model): +class NetworkProfileOutboundIPs(_serialization.Model): """Desired outbound IP resources for Azure Spring Cloud instance. Variables are only populated by the server, and will be ignored when sending a request. @@ -2166,24 +2050,20 @@ class NetworkProfileOutboundIPs(msrest.serialization.Model): """ _validation = { - 'public_i_ps': {'readonly': True}, + "public_i_ps": {"readonly": True}, } _attribute_map = { - 'public_i_ps': {'key': 'publicIPs', 'type': '[str]'}, + "public_i_ps": {"key": "publicIPs", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(NetworkProfileOutboundIPs, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.public_i_ps = None -class OperationDetail(msrest.serialization.Model): +class OperationDetail(_serialization.Model): """Operation detail payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2195,7 +2075,7 @@ class OperationDetail(msrest.serialization.Model): :ivar display: Display of the operation. :vartype display: ~azure.mgmt.appplatform.v2020_11_01_preview.models.OperationDisplay :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. Possible values include: "Internal". + internal only APIs. "Internal" :vartype action_type: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.ActionType :ivar origin: Origin of the operation. :vartype origin: str @@ -2204,16 +2084,16 @@ class OperationDetail(msrest.serialization.Model): """ _validation = { - 'action_type': {'readonly': True}, + "action_type": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'action_type': {'key': 'actionType', 'type': 'str'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "action_type": {"key": "actionType", "type": "str"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "OperationProperties"}, } def __init__( @@ -2221,9 +2101,9 @@ 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, - properties: Optional["OperationProperties"] = None, + properties: Optional["_models.OperationProperties"] = None, **kwargs ): """ @@ -2238,7 +2118,7 @@ def __init__( :keyword properties: Properties of the operation. :paramtype properties: ~azure.mgmt.appplatform.v2020_11_01_preview.models.OperationProperties """ - super(OperationDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display @@ -2247,7 +2127,7 @@ def __init__( self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display payload. :ivar provider: Resource provider of the operation. @@ -2261,10 +2141,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__( @@ -2286,14 +2166,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 OperationProperties(msrest.serialization.Model): +class OperationProperties(_serialization.Model): """Extra Operation properties. :ivar service_specification: Service specifications of the operation. @@ -2302,25 +2182,20 @@ class OperationProperties(msrest.serialization.Model): """ _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, } - def __init__( - self, - *, - service_specification: Optional["ServiceSpecification"] = None, - **kwargs - ): + def __init__(self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs): """ :keyword service_specification: Service specifications of the operation. :paramtype service_specification: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceSpecification """ - super(OperationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_specification = service_specification -class PersistentDisk(msrest.serialization.Model): +class PersistentDisk(_serialization.Model): """Persistent disk payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2334,69 +2209,56 @@ class PersistentDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 50, 'minimum': 0}, - 'used_in_gb': {'readonly': True, 'maximum': 50, 'minimum': 0}, + "size_in_gb": {"maximum": 50, "minimum": 0}, + "used_in_gb": {"readonly": True, "maximum": 50, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'used_in_gb': {'key': 'usedInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "used_in_gb": {"key": "usedInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: Optional[str] = None, **kwargs): """ :keyword size_in_gb: Size of the persistent disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the persistent disk. :paramtype mount_path: str """ - super(PersistentDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.used_in_gb = None self.mount_path = mount_path -class RegenerateTestKeyRequestPayload(msrest.serialization.Model): +class RegenerateTestKeyRequestPayload(_serialization.Model): """Regenerate test key request payload. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :ivar key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :vartype key_type: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.TestKeyType """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "TestKeyType"], - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.TestKeyType"], **kwargs): """ - :keyword key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :keyword key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :paramtype key_type: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.TestKeyType """ - super(RegenerateTestKeyRequestPayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type -class RequiredTraffic(msrest.serialization.Model): +class RequiredTraffic(_serialization.Model): """Required inbound or outbound traffic for Azure Spring Cloud instance. Variables are only populated by the server, and will be ignored when sending a request. @@ -2409,34 +2271,29 @@ class RequiredTraffic(msrest.serialization.Model): :vartype ips: list[str] :ivar fqdns: The FQDN list of required traffic. :vartype fqdns: list[str] - :ivar direction: The direction of required traffic. Possible values include: "Inbound", - "Outbound". + :ivar direction: The direction of required traffic. Known values are: "Inbound" and "Outbound". :vartype direction: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.TrafficDirection """ _validation = { - 'protocol': {'readonly': True}, - 'port': {'readonly': True}, - 'ips': {'readonly': True}, - 'fqdns': {'readonly': True}, - 'direction': {'readonly': True}, + "protocol": {"readonly": True}, + "port": {"readonly": True}, + "ips": {"readonly": True}, + "fqdns": {"readonly": True}, + "direction": {"readonly": True}, } _attribute_map = { - 'protocol': {'key': 'protocol', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - 'ips': {'key': 'ips', 'type': '[str]'}, - 'fqdns': {'key': 'fqdns', 'type': '[str]'}, - 'direction': {'key': 'direction', 'type': 'str'}, + "protocol": {"key": "protocol", "type": "str"}, + "port": {"key": "port", "type": "int"}, + "ips": {"key": "ips", "type": "[str]"}, + "fqdns": {"key": "fqdns", "type": "[str]"}, + "direction": {"key": "direction", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RequiredTraffic, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.protocol = None self.port = None self.ips = None @@ -2444,7 +2301,7 @@ def __init__( self.direction = None -class ResourceSku(msrest.serialization.Model): +class ResourceSku(_serialization.Model): """Describes an available Azure Spring Cloud SKU. :ivar resource_type: Gets the type of resource the SKU applies to. @@ -2468,13 +2325,13 @@ class ResourceSku(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'SkuCapacity'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[ResourceSkuLocationInfo]'}, - 'restrictions': {'key': 'restrictions', 'type': '[ResourceSkuRestrictions]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "SkuCapacity"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[ResourceSkuLocationInfo]"}, + "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, } def __init__( @@ -2483,10 +2340,10 @@ def __init__( resource_type: Optional[str] = None, name: Optional[str] = None, tier: Optional[str] = None, - capacity: Optional["SkuCapacity"] = None, + capacity: Optional["_models.SkuCapacity"] = None, locations: Optional[List[str]] = None, - location_info: Optional[List["ResourceSkuLocationInfo"]] = None, - restrictions: Optional[List["ResourceSkuRestrictions"]] = None, + location_info: Optional[List["_models.ResourceSkuLocationInfo"]] = None, + restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None, **kwargs ): """ @@ -2509,7 +2366,7 @@ def __init__( :paramtype restrictions: list[~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceSkuRestrictions] """ - super(ResourceSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.name = name self.tier = tier @@ -2519,7 +2376,7 @@ def __init__( self.restrictions = restrictions -class ResourceSkuCapabilities(msrest.serialization.Model): +class ResourceSkuCapabilities(_serialization.Model): """ResourceSkuCapabilities. :ivar name: Gets an invariant to describe the feature. @@ -2529,29 +2386,23 @@ class ResourceSkuCapabilities(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: Gets an invariant to describe the feature. :paramtype name: str :keyword value: Gets an invariant if the feature is measured by quantity. :paramtype value: str """ - super(ResourceSkuCapabilities, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class ResourceSkuCollection(msrest.serialization.Model): +class ResourceSkuCollection(_serialization.Model): """Object that includes an array of Azure Spring Cloud SKU and a possible link for next set. :ivar value: Collection of resource SKU. @@ -2562,16 +2413,12 @@ class ResourceSkuCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ResourceSku"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ResourceSku"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of resource SKU. @@ -2580,12 +2427,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ResourceSkuCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ResourceSkuLocationInfo(msrest.serialization.Model): +class ResourceSkuLocationInfo(_serialization.Model): """Locations and availability zones where the SKU is available. :ivar location: Gets location of the SKU. @@ -2598,9 +2445,9 @@ class ResourceSkuLocationInfo(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'zone_details': {'key': 'zoneDetails', 'type': '[ResourceSkuZoneDetails]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "zone_details": {"key": "zoneDetails", "type": "[ResourceSkuZoneDetails]"}, } def __init__( @@ -2608,7 +2455,7 @@ def __init__( *, location: Optional[str] = None, zones: Optional[List[str]] = None, - zone_details: Optional[List["ResourceSkuZoneDetails"]] = None, + zone_details: Optional[List["_models.ResourceSkuZoneDetails"]] = None, **kwargs ): """ @@ -2620,13 +2467,13 @@ def __init__( :paramtype zone_details: list[~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceSkuZoneDetails] """ - super(ResourceSkuLocationInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones self.zone_details = zone_details -class ResourceSkuRestrictionInfo(msrest.serialization.Model): +class ResourceSkuRestrictionInfo(_serialization.Model): """Information about the restriction where the SKU cannot be used. :ivar locations: Gets locations where the SKU is restricted. @@ -2636,33 +2483,27 @@ class ResourceSkuRestrictionInfo(msrest.serialization.Model): """ _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - locations: Optional[List[str]] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, locations: Optional[List[str]] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword locations: Gets locations where the SKU is restricted. :paramtype locations: list[str] :keyword zones: Gets list of availability zones where the SKU is restricted. :paramtype zones: list[str] """ - super(ResourceSkuRestrictionInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.locations = locations self.zones = zones -class ResourceSkuRestrictions(msrest.serialization.Model): +class ResourceSkuRestrictions(_serialization.Model): """Restrictions where the SKU cannot be used. - :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. Known + values are: "Location" and "Zone". :vartype type: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceSkuRestrictionsType :ivar values: Gets the value of restrictions. If the restriction type is set to @@ -2673,31 +2514,30 @@ class ResourceSkuRestrictions(msrest.serialization.Model): :vartype restriction_info: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceSkuRestrictionInfo :ivar reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceSkuRestrictionsReasonCode """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'ResourceSkuRestrictionInfo'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "restriction_info": {"key": "restrictionInfo", "type": "ResourceSkuRestrictionInfo"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceSkuRestrictionsType"]] = None, + type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None, values: Optional[List[str]] = None, - restriction_info: Optional["ResourceSkuRestrictionInfo"] = None, - reason_code: Optional[Union[str, "ResourceSkuRestrictionsReasonCode"]] = None, + restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None, + reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None, **kwargs ): """ :keyword type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + Known values are: "Location" and "Zone". :paramtype type: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceSkuRestrictionsType :keyword values: Gets the value of restrictions. If the restriction type is set to @@ -2708,19 +2548,18 @@ def __init__( :paramtype restriction_info: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceSkuRestrictionInfo :keyword reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceSkuRestrictionsReasonCode """ - super(ResourceSkuRestrictions, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.values = values self.restriction_info = restriction_info self.reason_code = reason_code -class ResourceSkuZoneDetails(msrest.serialization.Model): +class ResourceSkuZoneDetails(_serialization.Model): """Details of capabilities available to a SKU in specific zones. :ivar name: Gets the set of zones that the SKU is available in with the @@ -2733,15 +2572,15 @@ class ResourceSkuZoneDetails(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[ResourceSkuCapabilities]'}, + "name": {"key": "name", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, } def __init__( self, *, name: Optional[List[str]] = None, - capabilities: Optional[List["ResourceSkuCapabilities"]] = None, + capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None, **kwargs ): """ @@ -2753,12 +2592,12 @@ def __init__( :paramtype capabilities: list[~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceSkuCapabilities] """ - super(ResourceSkuZoneDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.capabilities = capabilities -class ResourceUploadDefinition(msrest.serialization.Model): +class ResourceUploadDefinition(_serialization.Model): """Resource upload definition payload. :ivar relative_path: Source relative path. @@ -2768,24 +2607,18 @@ class ResourceUploadDefinition(msrest.serialization.Model): """ _attribute_map = { - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'upload_url': {'key': 'uploadUrl', 'type': 'str'}, + "relative_path": {"key": "relativePath", "type": "str"}, + "upload_url": {"key": "uploadUrl", "type": "str"}, } - def __init__( - self, - *, - relative_path: Optional[str] = None, - upload_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, relative_path: Optional[str] = None, upload_url: Optional[str] = None, **kwargs): """ :keyword relative_path: Source relative path. :paramtype relative_path: str :keyword upload_url: Upload URL. :paramtype upload_url: str """ - super(ResourceUploadDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.relative_path = relative_path self.upload_url = upload_url @@ -2803,40 +2636,33 @@ class TrackedResource(Resource): :vartype type: str :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -2854,8 +2680,7 @@ class ServiceResource(TrackedResource): :vartype type: str :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] :ivar properties: Properties of the Service resource. :vartype properties: @@ -2865,19 +2690,19 @@ class ServiceResource(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ClusterResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "ClusterResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( @@ -2885,15 +2710,15 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - properties: Optional["ClusterResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.ClusterResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] :keyword properties: Properties of the Service resource. :paramtype properties: @@ -2901,12 +2726,12 @@ def __init__( :keyword sku: Sku of the Service resource. :paramtype sku: ~azure.mgmt.appplatform.v2020_11_01_preview.models.Sku """ - super(ServiceResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.properties = properties self.sku = sku -class ServiceResourceList(msrest.serialization.Model): +class ServiceResourceList(_serialization.Model): """Object that includes an array of Service resources and a possible link for next set. :ivar value: Collection of Service resources. @@ -2917,16 +2742,12 @@ class ServiceResourceList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ServiceResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ServiceResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Service resources. @@ -2935,12 +2756,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ServiceResourceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification payload. :ivar log_specifications: Specifications of the Log for Azure Monitoring. @@ -2952,15 +2773,15 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } def __init__( self, *, - log_specifications: Optional[List["LogSpecification"]] = None, - metric_specifications: Optional[List["MetricSpecification"]] = None, + log_specifications: Optional[List["_models.LogSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -2971,12 +2792,12 @@ def __init__( :paramtype metric_specifications: list[~azure.mgmt.appplatform.v2020_11_01_preview.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_specifications = log_specifications self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """Sku of Azure Spring Cloud. :ivar name: Name of the Sku. @@ -2988,19 +2809,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Optional[str] = "S0", - tier: Optional[str] = "Standard", - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: str = "S0", tier: str = "Standard", capacity: Optional[int] = None, **kwargs): """ :keyword name: Name of the Sku. :paramtype name: str @@ -3009,37 +2823,37 @@ def __init__( :keyword capacity: Current capacity of the target resource. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SkuCapacity(msrest.serialization.Model): +class SkuCapacity(_serialization.Model): """The SKU capacity. All required parameters must be populated in order to send to Azure. - :ivar minimum: Required. Gets or sets the minimum. + :ivar minimum: Gets or sets the minimum. Required. :vartype minimum: int :ivar maximum: Gets or sets the maximum. :vartype maximum: int :ivar default: Gets or sets the default. :vartype default: int - :ivar scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :ivar scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", and + "Automatic". :vartype scale_type: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.SkuScaleType """ _validation = { - 'minimum': {'required': True}, + "minimum": {"required": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } def __init__( @@ -3048,35 +2862,35 @@ def __init__( minimum: int, maximum: Optional[int] = None, default: Optional[int] = None, - scale_type: Optional[Union[str, "SkuScaleType"]] = None, + scale_type: Optional[Union[str, "_models.SkuScaleType"]] = None, **kwargs ): """ - :keyword minimum: Required. Gets or sets the minimum. + :keyword minimum: Gets or sets the minimum. Required. :paramtype minimum: int :keyword maximum: Gets or sets the maximum. :paramtype maximum: int :keyword default: Gets or sets the default. :paramtype default: int - :keyword scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :keyword scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", + and "Automatic". :paramtype scale_type: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.SkuScaleType """ - super(SkuCapacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.minimum = minimum self.maximum = maximum self.default = default self.scale_type = scale_type -class SupportedRuntimeVersion(msrest.serialization.Model): +class SupportedRuntimeVersion(_serialization.Model): """Supported deployment runtime version descriptor. - :ivar value: The raw value which could be passed to deployment CRUD operations. Possible values - include: "Java_8", "Java_11", "NetCore_31". + :ivar value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", and "NetCore_31". :vartype value: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.SupportedRuntimeValue - :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). Known + values are: "Java" and ".NET Core". :vartype platform: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.SupportedRuntimePlatform :ivar version: The detailed version (major.minor) of the platform. @@ -3084,38 +2898,38 @@ class SupportedRuntimeVersion(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'platform': {'key': 'platform', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "platform": {"key": "platform", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - value: Optional[Union[str, "SupportedRuntimeValue"]] = None, - platform: Optional[Union[str, "SupportedRuntimePlatform"]] = None, + value: Optional[Union[str, "_models.SupportedRuntimeValue"]] = None, + platform: Optional[Union[str, "_models.SupportedRuntimePlatform"]] = None, version: Optional[str] = None, **kwargs ): """ - :keyword value: The raw value which could be passed to deployment CRUD operations. Possible - values include: "Java_8", "Java_11", "NetCore_31". + :keyword value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", and "NetCore_31". :paramtype value: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.SupportedRuntimeValue :keyword platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + Known values are: "Java" and ".NET Core". :paramtype platform: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.SupportedRuntimePlatform :keyword version: The detailed version (major.minor) of the platform. :paramtype version: str """ - super(SupportedRuntimeVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.platform = platform self.version = version -class TemporaryDisk(msrest.serialization.Model): +class TemporaryDisk(_serialization.Model): """Temporary disk payload. :ivar size_in_gb: Size of the temporary disk in GB. @@ -3125,33 +2939,27 @@ class TemporaryDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 5, 'minimum': 0}, + "size_in_gb": {"maximum": 5, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = "/tmp", - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: str = "/tmp", **kwargs): """ :keyword size_in_gb: Size of the temporary disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the temporary disk. :paramtype mount_path: str """ - super(TemporaryDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.mount_path = mount_path -class TestKeys(msrest.serialization.Model): +class TestKeys(_serialization.Model): """Test keys payload. :ivar primary_key: Primary key. @@ -3167,11 +2975,11 @@ class TestKeys(msrest.serialization.Model): """ _attribute_map = { - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'primary_test_endpoint': {'key': 'primaryTestEndpoint', 'type': 'str'}, - 'secondary_test_endpoint': {'key': 'secondaryTestEndpoint', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "primary_test_endpoint": {"key": "primaryTestEndpoint", "type": "str"}, + "secondary_test_endpoint": {"key": "secondaryTestEndpoint", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, } def __init__( @@ -3196,7 +3004,7 @@ def __init__( :keyword enabled: Indicates whether the test endpoint feature enabled or not. :paramtype enabled: bool """ - super(TestKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_key = primary_key self.secondary_key = secondary_key self.primary_test_endpoint = primary_test_endpoint @@ -3204,11 +3012,10 @@ def __init__( self.enabled = enabled -class UserSourceInfo(msrest.serialization.Model): +class UserSourceInfo(_serialization.Model): """Source information for a deployment. - :ivar type: Type of the source uploaded. Possible values include: "Jar", "NetCoreZip", - "Source". + :ivar type: Type of the source uploaded. Known values are: "Jar", "NetCoreZip", and "Source". :vartype type: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.UserSourceType :ivar relative_path: Relative path of the storage which stores the source. :vartype relative_path: str @@ -3221,23 +3028,23 @@ class UserSourceInfo(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'artifact_selector': {'key': 'artifactSelector', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "artifact_selector": {"key": "artifactSelector", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "UserSourceType"]] = None, + type: Optional[Union[str, "_models.UserSourceType"]] = None, relative_path: Optional[str] = None, version: Optional[str] = None, artifact_selector: Optional[str] = None, **kwargs ): """ - :keyword type: Type of the source uploaded. Possible values include: "Jar", "NetCoreZip", + :keyword type: Type of the source uploaded. Known values are: "Jar", "NetCoreZip", and "Source". :paramtype type: str or ~azure.mgmt.appplatform.v2020_11_01_preview.models.UserSourceType :keyword relative_path: Relative path of the storage which stores the source. @@ -3249,7 +3056,7 @@ def __init__( the relative path to the target module/project. :paramtype artifact_selector: str """ - super(UserSourceInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.relative_path = relative_path self.version = version diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/__init__.py index aa6fe5cd0cfc..a3674f282ddb 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/__init__.py @@ -18,16 +18,22 @@ from ._runtime_versions_operations import RuntimeVersionsOperations from ._skus_operations import SkusOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', + "ServicesOperations", + "ConfigServersOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_apps_operations.py index 9827c7a11de2..6bf55bf3f5de 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_apps_operations.py @@ -6,341 +6,313 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, sync_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 sync_status is not None: - _query_parameters['syncStatus'] = _SERIALIZER.query("sync_status", sync_status, 'str') + _params["syncStatus"] = _SERIALIZER.query("sync_status", sync_status, "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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str +def build_list_request(resource_group_name: str, service_name: str, 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_resource_upload_url_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_validate_domain_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class AppsOperations(object): - """AppsOperations 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.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.AppPlatformManagementClient`'s + :attr:`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 get( @@ -350,102 +322,125 @@ def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -453,21 +448,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -475,20 +549,24 @@ def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -501,84 +579,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -588,25 +677,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -618,83 +702,107 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -702,18 +810,97 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -721,20 +908,24 @@ def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -747,104 +938,120 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AppResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -858,10 +1065,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 @@ -871,74 +1076,138 @@ 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.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def validate_domain( @@ -946,67 +1215,86 @@ def validate_domain( resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: Union[_models.CustomDomainValidatePayload, IO], **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. :type validate_payload: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainValidatePayload + ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_bindings_operations.py index e2701b47109b..063ead004753 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_bindings_operations.py @@ -6,330 +6,310 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class BindingsOperations(object): - """BindingsOperations 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.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +317,55 @@ def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -377,21 +373,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +481,27 @@ def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +514,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +536,75 @@ def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -518,28 +614,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -551,46 +641,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _update_initial( self, @@ -598,39 +696,55 @@ def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -638,18 +752,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +857,27 @@ def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +890,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +912,104 @@ def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +1023,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 @@ -816,8 +1034,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_certificates_operations.py index 4ff2be514678..10be9424f879 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_certificates_operations.py @@ -6,308 +6,317 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - 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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 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.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", 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.appplatform.v2020_11_01_preview.AppPlatformManagementClient`'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 get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(certificate_resource, 'CertificateResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -315,21 +324,101 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -337,21 +426,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> LROPoller["_models.CertificateResource"]: + ) -> LROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type certificate_resource: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource + ~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -364,84 +457,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -451,25 +555,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -481,98 +580,117 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +704,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 @@ -599,8 +715,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_config_servers_operations.py index 346ea8f011e5..a74d4f74abb9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_config_servers_operations.py @@ -6,311 +6,311 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_validate_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ConfigServersOperations(object): - """ConfigServersOperations 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.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -318,37 +318,115 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -361,86 +439,109 @@ def begin_update_put( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -448,37 +549,115 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -491,86 +670,109 @@ def begin_update_patch( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_settings, 'ConfigServerSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -578,37 +780,115 @@ def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerSettings + ~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -621,47 +901,54 @@ def begin_validate( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_custom_domains_operations.py index 62862ed6d0f7..2c8f982ecd52 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_custom_domains_operations.py @@ -6,330 +6,310 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class CustomDomainsOperations(object): - """CustomDomainsOperations 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.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +317,55 @@ def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -377,21 +373,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +481,27 @@ def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +514,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +536,75 @@ def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -518,28 +614,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -551,46 +641,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _update_initial( self, @@ -598,39 +696,55 @@ def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -638,18 +752,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +857,27 @@ def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +890,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +912,105 @@ def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +1024,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 @@ -816,8 +1035,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_deployments_operations.py index e5e73f785557..056665f89275 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_deployments_operations.py @@ -6,534 +6,538 @@ # Code generated 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, List, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_delete_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_for_cluster_request( - subscription_id: str, resource_group_name: str, service_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_start_request_initial( - subscription_id: str, +def build_start_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_stop_request_initial( - subscription_id: str, +def build_stop_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request_initial( - subscription_id: str, +def build_restart_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_get_log_file_url_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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 DeploymentsOperations(object): - """DeploymentsOperations 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.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( self, @@ -541,39 +545,55 @@ def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -581,21 +601,107 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -604,23 +710,27 @@ def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -633,19 +743,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -653,67 +765,75 @@ def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -723,28 +843,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -756,46 +870,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _update_initial( self, @@ -803,39 +925,55 @@ def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -843,18 +981,104 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -863,23 +1087,27 @@ def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -892,19 +1120,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -912,32 +1142,37 @@ def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -947,60 +1182,72 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + ) -> Iterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1014,10 +1261,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 @@ -1027,69 +1272,76 @@ 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1103,10 +1355,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 @@ -1116,46 +1366,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1165,28 +1416,22 @@ def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1198,81 +1443,92 @@ def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1282,28 +1538,22 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1315,81 +1565,92 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -1399,28 +1660,22 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace - def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1432,98 +1687,109 @@ def begin_restart( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1532,12 +1798,11 @@ def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_monitoring_settings_operations.py index 87a792fc8dd7..ac831c7a8b7e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_monitoring_settings_operations.py @@ -6,267 +6,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 MonitoringSettingsOperations(object): - """MonitoringSettingsOperations 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.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -274,37 +282,115 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -317,86 +403,109 @@ def begin_update_put( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -404,37 +513,115 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation 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,47 +634,54 @@ def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_operations.py index ae325f2a61c4..a7458016d80d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_operations.py @@ -6,111 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - accept = "application/json" +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/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.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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.appplatform.v2020_11_01_preview.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,10 +147,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 +158,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_runtime_versions_operations.py index 1d749404a66e..11e2662bba6d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_runtime_versions_operations.py @@ -6,117 +6,128 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from 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 -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_runtime_versions_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - accept = "application/json" +def build_list_runtime_versions_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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/runtimeVersions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 RuntimeVersionsOperations(object): - """RuntimeVersionsOperations 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.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_services_operations.py index cd97246f6946..91244e4ac3c1 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_services_operations.py @@ -6,564 +6,530 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_test_keys_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_regenerate_test_key_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/regenerateTestKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_disable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_enable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_check_name_availability_request( - subscription_id: str, - location: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "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 - ) - - -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 ServicesOperations(object): - """ServicesOperations 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.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -571,39 +537,43 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -616,81 +586,162 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] + :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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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 [202, 204]: @@ -700,22 +751,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -727,80 +772,100 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -808,36 +873,40 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -850,220 +919,379 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] + :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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2020_11_01_preview.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2020_11_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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', "2020-11-01-preview") # 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", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -1073,170 +1301,245 @@ def disable_test_endpoint( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace - def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def enable_test_endpoint(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - @distributed_trace + @overload def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2020_11_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2020_11_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2020_11_01_preview.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] - _json = self._serialize.body(availability_parameters, 'NameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1250,10 +1553,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 @@ -1263,58 +1564,68 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1328,10 +1639,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 @@ -1341,8 +1650,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_skus_operations.py index a3281080aeae..7f7f8097c7e7 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2020_11_01_preview/operations/_skus_operations.py @@ -6,120 +6,140 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 SkusOperations(object): - """SkusOperations 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.appplatform.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2020_11_01_preview.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) + :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2020_11_01_preview.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # type: Literal["2020-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -133,10 +153,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 @@ -146,8 +164,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/__init__.py index 41ec6d71ff7f..a6bfaa2de14d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_app_platform_management_client.py index 58dad04d7115..3535ad77c4d8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_app_platform_management_client.py @@ -9,20 +9,32 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import AppPlatformManagementClientConfiguration -from .operations import AppsOperations, BindingsOperations, CertificatesOperations, ConfigServersOperations, CustomDomainsOperations, DeploymentsOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServicesOperations, SkusOperations +from .operations import ( + AppsOperations, + BindingsOperations, + CertificatesOperations, + ConfigServersOperations, + CustomDomainsOperations, + DeploymentsOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServicesOperations, + SkusOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Cloud. :ivar services: ServicesOperations operations @@ -53,10 +65,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib azure.mgmt.appplatform.v2021_06_01_preview.operations.RuntimeVersionsOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.appplatform.v2021_06_01_preview.operations.SkusOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -74,7 +86,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -83,22 +97,21 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -107,7 +120,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_configuration.py index 2e1de152bfab..c7827ef2ba08 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-06-01-preview") # type: Literal["2021-06-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_metadata.json b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_metadata.json index 92b71dccabf3..de6d067bd667 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_metadata.json +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}, \"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\": [\"AppPlatformManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -109,4 +109,4 @@ "runtime_versions": "RuntimeVersionsOperations", "skus": "SkusOperations" } -} \ No newline at end of file +} diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_vendor.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_vendor.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_version.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_version.py index e7ffc58c0429..92453d8691d9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_version.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.1.0" +VERSION = "6.1.0" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/__init__.py index 44ce4a5043f8..398c48287ad8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._app_platform_management_client import AppPlatformManagementClient -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/_app_platform_management_client.py index 00782ca39427..27281616bb20 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/_app_platform_management_client.py @@ -9,20 +9,32 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import AppPlatformManagementClientConfiguration -from .operations import AppsOperations, BindingsOperations, CertificatesOperations, ConfigServersOperations, CustomDomainsOperations, DeploymentsOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServicesOperations, SkusOperations +from .operations import ( + AppsOperations, + BindingsOperations, + CertificatesOperations, + ConfigServersOperations, + CustomDomainsOperations, + DeploymentsOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServicesOperations, + SkusOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Cloud. :ivar services: ServicesOperations operations @@ -53,10 +65,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib azure.mgmt.appplatform.v2021_06_01_preview.aio.operations.RuntimeVersionsOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.appplatform.v2021_06_01_preview.aio.operations.SkusOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -74,7 +86,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -83,22 +97,21 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -107,7 +120,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/_configuration.py index fbe7cbe198a5..5b7733277a14 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-06-01-preview") # type: Literal["2021-06-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/__init__.py index aa6fe5cd0cfc..a3674f282ddb 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/__init__.py @@ -18,16 +18,22 @@ from ._runtime_versions_operations import RuntimeVersionsOperations from ._skus_operations import SkusOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', + "ServicesOperations", + "ConfigServersOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_apps_operations.py index e4832b4a1e8d..f875e4455427 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_apps_operations.py @@ -6,46 +6,67 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._apps_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_get_resource_upload_url_request, build_list_request, build_update_request_initial, build_validate_domain_request -T = TypeVar('T') +from ...operations._apps_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_get_resource_upload_url_request, + build_list_request, + build_update_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AppsOperations: - """AppsOperations 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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.aio.AppPlatformManagementClient`'s + :attr:`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_async async def get( @@ -55,102 +76,125 @@ async def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -158,21 +202,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,20 +303,24 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -206,84 +333,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -293,25 +432,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -323,83 +457,108 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -407,18 +566,97 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -426,20 +664,24 @@ async def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -452,104 +694,121 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncIterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AppResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -563,10 +822,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 @@ -576,74 +833,138 @@ 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.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace_async async def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def validate_domain( @@ -651,67 +972,86 @@ async def validate_domain( resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: Union[_models.CustomDomainValidatePayload, IO], **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. :type validate_payload: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainValidatePayload + ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_bindings_operations.py index 0f2eec3773b6..5eea5dfd7bc8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_bindings_operations.py @@ -6,113 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._bindings_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._bindings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BindingsOperations: - """BindingsOperations 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 BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.aio.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +141,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -160,21 +197,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +305,27 @@ async def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +338,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +360,76 @@ async def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -301,28 +439,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -334,46 +466,55 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _update_initial( self, @@ -381,39 +522,55 @@ async def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -421,18 +578,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +683,27 @@ async def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +716,21 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +738,105 @@ async def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +850,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 @@ -599,8 +861,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_certificates_operations.py index f7706159a0d1..a33fd6ed2d29 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_certificates_operations.py @@ -6,147 +6,184 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class 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.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.aio.AppPlatformManagementClient`'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_async async def get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(certificate_resource, 'CertificateResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -154,21 +191,101 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -176,21 +293,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CertificateResource"]: + ) -> AsyncLROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type certificate_resource: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource + ~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -203,84 +324,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -290,25 +423,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -320,98 +448,118 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -425,10 +573,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 @@ -438,8 +584,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_config_servers_operations.py index cb88c6e435df..586ce9cb1959 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_config_servers_operations.py @@ -6,139 +6,174 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._config_servers_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial, build_validate_request_initial -T = TypeVar('T') +from ...operations._config_servers_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConfigServersOperations: - """ConfigServersOperations 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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.aio.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,37 +181,115 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,86 +302,110 @@ async def begin_update_put( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -276,37 +413,115 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -319,86 +534,110 @@ async def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_settings, 'ConfigServerSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -406,37 +645,115 @@ async def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerSettings + ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -449,47 +766,54 @@ async def begin_validate( or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = await self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_custom_domains_operations.py index 5f08b6fde073..bd603e73646f 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_custom_domains_operations.py @@ -6,113 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._custom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CustomDomainsOperations: - """CustomDomainsOperations 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 CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.aio.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +141,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -160,21 +197,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +305,27 @@ async def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +338,21 @@ async def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +360,76 @@ async def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -301,28 +439,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -334,46 +466,55 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _update_initial( self, @@ -381,39 +522,55 @@ async def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -421,18 +578,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +683,27 @@ async def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +716,21 @@ async def begin_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +738,106 @@ async def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +851,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 @@ -599,8 +862,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_deployments_operations.py index 7708eb9322bf..bca05ebdd432 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_deployments_operations.py @@ -6,113 +6,139 @@ # Code generated 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, List, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._deployments_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_log_file_url_request, build_get_request, build_list_for_cluster_request, build_list_request, build_restart_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._deployments_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_log_file_url_request, + build_get_request, + build_list_for_cluster_request, + build_list_request, + build_restart_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeploymentsOperations: - """DeploymentsOperations 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 DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.aio.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +146,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -160,21 +202,107 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,23 +311,27 @@ async def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -212,19 +344,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -232,67 +366,76 @@ async def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -302,28 +445,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -335,46 +472,55 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _update_initial( self, @@ -382,39 +528,55 @@ async def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -422,18 +584,104 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -442,23 +690,27 @@ async def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -471,19 +723,21 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -491,32 +745,38 @@ async def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -526,60 +786,72 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + ) -> AsyncIterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -593,10 +865,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 @@ -606,69 +876,76 @@ 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -682,10 +959,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 @@ -695,46 +970,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -744,28 +1020,22 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -777,81 +1047,93 @@ async def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -861,28 +1143,22 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -894,81 +1170,93 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore async def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -978,28 +1266,22 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async - async def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1011,98 +1293,110 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async async def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1111,12 +1405,11 @@ async def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_monitoring_settings_operations.py index a77221d1d11a..29eda22f1aec 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_monitoring_settings_operations.py @@ -6,139 +6,175 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._monitoring_settings_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial -T = TypeVar('T') +from ...operations._monitoring_settings_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MonitoringSettingsOperations: - """MonitoringSettingsOperations 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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.aio.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,37 +182,115 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,86 +303,110 @@ async def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -276,37 +414,115 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -319,47 +535,55 @@ async def begin_update_patch( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_operations.py index aa02a22d893c..08f1f30b423d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_operations.py @@ -6,82 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.aio.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.appplatform.v2021_06_01_preview.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,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 @@ -108,8 +134,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_runtime_versions_operations.py index 5a041d1ced20..f561f3e169a2 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_runtime_versions_operations.py @@ -6,88 +6,104 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import 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._runtime_versions_operations import build_list_runtime_versions_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RuntimeVersionsOperations: - """RuntimeVersionsOperations 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 RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.aio.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + async def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_services_operations.py index 781ed3086c6d..114882c2df02 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_services_operations.py @@ -6,141 +6,180 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._services_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_disable_test_endpoint_request, build_enable_test_endpoint_request, build_get_request, build_list_by_subscription_request, build_list_request, build_list_test_keys_request, build_regenerate_test_key_request, build_update_request_initial -T = TypeVar('T') +from ...operations._services_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_disable_test_endpoint_request, + build_enable_test_endpoint_request, + build_get_request, + build_list_by_subscription_request, + build_list_request, + build_list_test_keys_request, + build_regenerate_test_key_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ServicesOperations: - """ServicesOperations 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 ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.aio.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -148,39 +187,43 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -193,81 +236,163 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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 [202, 204]: @@ -277,22 +402,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -304,80 +423,101 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -385,36 +525,40 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -427,220 +571,380 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + async def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2021_06_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace_async async def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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', "2021-06-01-preview") # 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -650,170 +954,247 @@ async def disable_test_endpoint( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace_async async def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2021_06_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] - _json = self._serialize.body(availability_parameters, 'NameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -827,10 +1208,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 @@ -840,58 +1219,68 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -905,10 +1294,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 @@ -918,8 +1305,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_skus_operations.py index 587c38326964..60fafc0e3c74 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/aio/operations/_skus_operations.py @@ -6,85 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SkusOperations: - """SkusOperations 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 SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.aio.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) + :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -98,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 @@ -111,8 +135,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/__init__.py index 63bc9d3ed371..ac4d78cc8014 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/__init__.py @@ -79,115 +79,117 @@ from ._models_py3 import TrackedResource from ._models_py3 import UserSourceInfo - -from ._app_platform_management_client_enums import ( - ActionType, - AppResourceProvisioningState, - ConfigServerState, - DeploymentResourceProvisioningState, - DeploymentResourceStatus, - ManagedIdentityType, - MonitoringSettingState, - ProvisioningState, - ResourceSkuRestrictionsReasonCode, - ResourceSkuRestrictionsType, - RuntimeVersion, - SkuScaleType, - SupportedRuntimePlatform, - SupportedRuntimeValue, - TestKeyType, - TrafficDirection, - UserSourceType, -) +from ._app_platform_management_client_enums import ActionType +from ._app_platform_management_client_enums import AppResourceProvisioningState +from ._app_platform_management_client_enums import ConfigServerState +from ._app_platform_management_client_enums import DeploymentResourceProvisioningState +from ._app_platform_management_client_enums import DeploymentResourceStatus +from ._app_platform_management_client_enums import ManagedIdentityType +from ._app_platform_management_client_enums import MonitoringSettingState +from ._app_platform_management_client_enums import ProvisioningState +from ._app_platform_management_client_enums import ResourceSkuRestrictionsReasonCode +from ._app_platform_management_client_enums import ResourceSkuRestrictionsType +from ._app_platform_management_client_enums import RuntimeVersion +from ._app_platform_management_client_enums import SkuScaleType +from ._app_platform_management_client_enums import SupportedRuntimePlatform +from ._app_platform_management_client_enums import SupportedRuntimeValue +from ._app_platform_management_client_enums import TestKeyType +from ._app_platform_management_client_enums import TrafficDirection +from ._app_platform_management_client_enums import UserSourceType +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__ = [ - 'AppResource', - 'AppResourceCollection', - 'AppResourceProperties', - 'ApplicationInsightsAgentVersions', - 'AvailableOperations', - 'AvailableRuntimeVersions', - 'BindingResource', - 'BindingResourceCollection', - 'BindingResourceProperties', - 'CertificateProperties', - 'CertificateResource', - 'CertificateResourceCollection', - 'CloudErrorBody', - 'ClusterResourceProperties', - 'ConfigServerGitProperty', - 'ConfigServerProperties', - 'ConfigServerResource', - 'ConfigServerSettings', - 'ConfigServerSettingsErrorRecord', - 'ConfigServerSettingsValidateResult', - 'CustomContainer', - 'CustomDomainProperties', - 'CustomDomainResource', - 'CustomDomainResourceCollection', - 'CustomDomainValidatePayload', - 'CustomDomainValidateResult', - 'DeploymentInstance', - 'DeploymentResource', - 'DeploymentResourceCollection', - 'DeploymentResourceProperties', - 'DeploymentSettings', - 'Error', - 'GitPatternRepository', - 'ImageRegistryCredential', - 'LogFileUrlResponse', - 'LogSpecification', - 'ManagedIdentityProperties', - 'MetricDimension', - 'MetricSpecification', - 'MonitoringSettingProperties', - 'MonitoringSettingResource', - 'NameAvailability', - 'NameAvailabilityParameters', - 'NetworkProfile', - 'NetworkProfileOutboundIPs', - 'OperationDetail', - 'OperationDisplay', - 'OperationProperties', - 'PersistentDisk', - 'ProxyResource', - 'RegenerateTestKeyRequestPayload', - 'RequiredTraffic', - 'Resource', - 'ResourceRequests', - 'ResourceSku', - 'ResourceSkuCapabilities', - 'ResourceSkuCollection', - 'ResourceSkuLocationInfo', - 'ResourceSkuRestrictionInfo', - 'ResourceSkuRestrictions', - 'ResourceSkuZoneDetails', - 'ResourceUploadDefinition', - 'ServiceResource', - 'ServiceResourceList', - 'ServiceSpecification', - 'Sku', - 'SkuCapacity', - 'SupportedRuntimeVersion', - 'TemporaryDisk', - 'TestKeys', - 'TrackedResource', - 'UserSourceInfo', - 'ActionType', - 'AppResourceProvisioningState', - 'ConfigServerState', - 'DeploymentResourceProvisioningState', - 'DeploymentResourceStatus', - 'ManagedIdentityType', - 'MonitoringSettingState', - 'ProvisioningState', - 'ResourceSkuRestrictionsReasonCode', - 'ResourceSkuRestrictionsType', - 'RuntimeVersion', - 'SkuScaleType', - 'SupportedRuntimePlatform', - 'SupportedRuntimeValue', - 'TestKeyType', - 'TrafficDirection', - 'UserSourceType', + "AppResource", + "AppResourceCollection", + "AppResourceProperties", + "ApplicationInsightsAgentVersions", + "AvailableOperations", + "AvailableRuntimeVersions", + "BindingResource", + "BindingResourceCollection", + "BindingResourceProperties", + "CertificateProperties", + "CertificateResource", + "CertificateResourceCollection", + "CloudErrorBody", + "ClusterResourceProperties", + "ConfigServerGitProperty", + "ConfigServerProperties", + "ConfigServerResource", + "ConfigServerSettings", + "ConfigServerSettingsErrorRecord", + "ConfigServerSettingsValidateResult", + "CustomContainer", + "CustomDomainProperties", + "CustomDomainResource", + "CustomDomainResourceCollection", + "CustomDomainValidatePayload", + "CustomDomainValidateResult", + "DeploymentInstance", + "DeploymentResource", + "DeploymentResourceCollection", + "DeploymentResourceProperties", + "DeploymentSettings", + "Error", + "GitPatternRepository", + "ImageRegistryCredential", + "LogFileUrlResponse", + "LogSpecification", + "ManagedIdentityProperties", + "MetricDimension", + "MetricSpecification", + "MonitoringSettingProperties", + "MonitoringSettingResource", + "NameAvailability", + "NameAvailabilityParameters", + "NetworkProfile", + "NetworkProfileOutboundIPs", + "OperationDetail", + "OperationDisplay", + "OperationProperties", + "PersistentDisk", + "ProxyResource", + "RegenerateTestKeyRequestPayload", + "RequiredTraffic", + "Resource", + "ResourceRequests", + "ResourceSku", + "ResourceSkuCapabilities", + "ResourceSkuCollection", + "ResourceSkuLocationInfo", + "ResourceSkuRestrictionInfo", + "ResourceSkuRestrictions", + "ResourceSkuZoneDetails", + "ResourceUploadDefinition", + "ServiceResource", + "ServiceResourceList", + "ServiceSpecification", + "Sku", + "SkuCapacity", + "SupportedRuntimeVersion", + "TemporaryDisk", + "TestKeys", + "TrackedResource", + "UserSourceInfo", + "ActionType", + "AppResourceProvisioningState", + "ConfigServerState", + "DeploymentResourceProvisioningState", + "DeploymentResourceStatus", + "ManagedIdentityType", + "MonitoringSettingState", + "ProvisioningState", + "ResourceSkuRestrictionsReasonCode", + "ResourceSkuRestrictionsType", + "RuntimeVersion", + "SkuScaleType", + "SupportedRuntimePlatform", + "SupportedRuntimeValue", + "TestKeyType", + "TrafficDirection", + "UserSourceType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/_app_platform_management_client_enums.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/_app_platform_management_client_enums.py index fa72f83379ee..c580595a521c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/_app_platform_management_client_enums.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/_app_platform_management_client_enums.py @@ -7,28 +7,26 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - """ +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" INTERNAL = "Internal" -class AppResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the App - """ + +class AppResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the App.""" SUCCEEDED = "Succeeded" FAILED = "Failed" CREATING = "Creating" UPDATING = "Updating" -class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the config server. - """ + +class ConfigServerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the config server.""" NOT_AVAILABLE = "NotAvailable" DELETED = "Deleted" @@ -36,18 +34,18 @@ class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class DeploymentResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Deployment - """ + +class DeploymentResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Deployment.""" CREATING = "Creating" UPDATING = "Updating" SUCCEEDED = "Succeeded" FAILED = "Failed" -class DeploymentResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of the Deployment - """ + +class DeploymentResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the Deployment.""" UNKNOWN = "Unknown" STOPPED = "Stopped" @@ -57,27 +55,27 @@ class DeploymentResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum UPGRADING = "Upgrading" COMPILING = "Compiling" -class ManagedIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the managed identity - """ + +class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the managed identity.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class MonitoringSettingState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Monitoring Setting. - """ + +class MonitoringSettingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Monitoring Setting.""" NOT_AVAILABLE = "NotAvailable" FAILED = "Failed" SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Service - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Service.""" CREATING = "Creating" UPDATING = "Updating" @@ -89,69 +87,70 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MOVED = "Moved" MOVE_FAILED = "MoveFailed" -class ResourceSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription' + 'NotAvailableForSubscription'. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ResourceSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets the type of restrictions. Possible values include: 'Location', 'Zone' - """ + +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the type of restrictions. Possible values include: 'Location', 'Zone'.""" LOCATION = "Location" ZONE = "Zone" -class RuntimeVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Runtime version - """ + +class RuntimeVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Runtime version.""" JAVA8 = "Java_8" JAVA11 = "Java_11" NET_CORE31 = "NetCore_31" -class SkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets or sets the type of the scale. - """ + +class SkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type of the scale.""" NONE = "None" MANUAL = "Manual" AUTOMATIC = "Automatic" -class SupportedRuntimePlatform(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The platform of this runtime version (possible values: "Java" or ".NET"). - """ + +class SupportedRuntimePlatform(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The platform of this runtime version (possible values: "Java" or ".NET").""" JAVA = "Java" _NET_CORE = ".NET Core" -class SupportedRuntimeValue(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The raw value which could be passed to deployment CRUD operations. - """ + +class SupportedRuntimeValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The raw value which could be passed to deployment CRUD operations.""" JAVA8 = "Java_8" JAVA11 = "Java_11" NET_CORE31 = "NetCore_31" -class TestKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the test key - """ + +class TestKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the test key.""" PRIMARY = "Primary" SECONDARY = "Secondary" -class TrafficDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The direction of required traffic - """ + +class TrafficDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The direction of required traffic.""" INBOUND = "Inbound" OUTBOUND = "Outbound" -class UserSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the source uploaded - """ + +class UserSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the source uploaded.""" JAR = "Jar" NET_CORE_ZIP = "NetCoreZip" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/_models_py3.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/_models_py3.py index 1cd1bb6ef9ec..54b9f31dbee7 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/_models_py3.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._app_platform_management_client_enums import * +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ApplicationInsightsAgentVersions(msrest.serialization.Model): + +class ApplicationInsightsAgentVersions(_serialization.Model): """Application Insights agent versions properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -23,24 +33,20 @@ class ApplicationInsightsAgentVersions(msrest.serialization.Model): """ _validation = { - 'java': {'readonly': True}, + "java": {"readonly": True}, } _attribute_map = { - 'java': {'key': 'java', 'type': 'str'}, + "java": {"key": "java", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApplicationInsightsAgentVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.java = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The core properties of ARM resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -54,24 +60,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -91,24 +93,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class AppResource(ProxyResource): @@ -131,25 +129,25 @@ class AppResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'AppResourceProperties'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentityProperties'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "AppResourceProperties"}, + "identity": {"key": "identity", "type": "ManagedIdentityProperties"}, + "location": {"key": "location", "type": "str"}, } def __init__( self, *, - properties: Optional["AppResourceProperties"] = None, - identity: Optional["ManagedIdentityProperties"] = None, + properties: Optional["_models.AppResourceProperties"] = None, + identity: Optional["_models.ManagedIdentityProperties"] = None, location: Optional[str] = None, **kwargs ): @@ -163,13 +161,13 @@ def __init__( resource. :paramtype location: str """ - super(AppResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.identity = identity self.location = location -class AppResourceCollection(msrest.serialization.Model): +class AppResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of App resources. @@ -180,16 +178,12 @@ class AppResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AppResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AppResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["AppResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.AppResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of App resources. @@ -198,12 +192,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(AppResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class AppResourceProperties(msrest.serialization.Model): +class AppResourceProperties(_serialization.Model): """App resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -212,8 +206,8 @@ class AppResourceProperties(msrest.serialization.Model): :vartype public: bool :ivar url: URL of the App. :vartype url: str - :ivar provisioning_state: Provisioning state of the App. Possible values include: "Succeeded", - "Failed", "Creating", "Updating". + :ivar provisioning_state: Provisioning state of the App. Known values are: "Succeeded", + "Failed", "Creating", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResourceProvisioningState :ivar active_deployment_name: Name of the active deployment of the App. @@ -233,22 +227,22 @@ class AppResourceProperties(msrest.serialization.Model): """ _validation = { - 'url': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'created_time': {'readonly': True}, + "url": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "created_time": {"readonly": True}, } _attribute_map = { - 'public': {'key': 'public', 'type': 'bool'}, - 'url': {'key': 'url', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'active_deployment_name': {'key': 'activeDeploymentName', 'type': 'str'}, - 'fqdn': {'key': 'fqdn', 'type': 'str'}, - 'https_only': {'key': 'httpsOnly', 'type': 'bool'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'temporary_disk': {'key': 'temporaryDisk', 'type': 'TemporaryDisk'}, - 'persistent_disk': {'key': 'persistentDisk', 'type': 'PersistentDisk'}, - 'enable_end_to_end_tls': {'key': 'enableEndToEndTLS', 'type': 'bool'}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "active_deployment_name": {"key": "activeDeploymentName", "type": "str"}, + "fqdn": {"key": "fqdn", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "temporary_disk": {"key": "temporaryDisk", "type": "TemporaryDisk"}, + "persistent_disk": {"key": "persistentDisk", "type": "PersistentDisk"}, + "enable_end_to_end_tls": {"key": "enableEndToEndTLS", "type": "bool"}, } def __init__( @@ -257,10 +251,10 @@ def __init__( public: Optional[bool] = None, active_deployment_name: Optional[str] = None, fqdn: Optional[str] = None, - https_only: Optional[bool] = False, - temporary_disk: Optional["TemporaryDisk"] = None, - persistent_disk: Optional["PersistentDisk"] = None, - enable_end_to_end_tls: Optional[bool] = False, + https_only: bool = False, + temporary_disk: Optional["_models.TemporaryDisk"] = None, + persistent_disk: Optional["_models.PersistentDisk"] = None, + enable_end_to_end_tls: bool = False, **kwargs ): """ @@ -279,7 +273,7 @@ def __init__( :keyword enable_end_to_end_tls: Indicate if end to end TLS is enabled. :paramtype enable_end_to_end_tls: bool """ - super(AppResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.public = public self.url = None self.provisioning_state = None @@ -292,7 +286,7 @@ def __init__( self.enable_end_to_end_tls = enable_end_to_end_tls -class AvailableOperations(msrest.serialization.Model): +class AvailableOperations(_serialization.Model): """Available operations of the service. :ivar value: Collection of available operation details. @@ -303,16 +297,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. @@ -321,12 +311,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 AvailableRuntimeVersions(msrest.serialization.Model): +class AvailableRuntimeVersions(_serialization.Model): """AvailableRuntimeVersions. Variables are only populated by the server, and will be ignored when sending a request. @@ -337,20 +327,16 @@ class AvailableRuntimeVersions(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedRuntimeVersion]'}, + "value": {"key": "value", "type": "[SupportedRuntimeVersion]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AvailableRuntimeVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -371,34 +357,29 @@ class BindingResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'BindingResourceProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "BindingResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["BindingResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BindingResourceProperties"] = None, **kwargs): """ :keyword properties: Properties of the Binding resource. :paramtype properties: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResourceProperties """ - super(BindingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BindingResourceCollection(msrest.serialization.Model): +class BindingResourceCollection(_serialization.Model): """Object that includes an array of Binding resources and a possible link for next set. :ivar value: Collection of Binding resources. @@ -409,16 +390,12 @@ class BindingResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BindingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BindingResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BindingResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Binding resources. @@ -427,12 +404,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BindingResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BindingResourceProperties(msrest.serialization.Model): +class BindingResourceProperties(_serialization.Model): """Binding resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -446,7 +423,7 @@ class BindingResourceProperties(msrest.serialization.Model): :ivar key: The key of the bound resource. :vartype key: str :ivar binding_parameters: Binding parameters of the Binding resource. - :vartype binding_parameters: dict[str, any] + :vartype binding_parameters: dict[str, JSON] :ivar generated_properties: The generated Spring Boot property file for this binding. The secret will be deducted. :vartype generated_properties: str @@ -457,22 +434,22 @@ class BindingResourceProperties(msrest.serialization.Model): """ _validation = { - 'resource_name': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'generated_properties': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, + "resource_name": {"readonly": True}, + "resource_type": {"readonly": True}, + "generated_properties": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, } _attribute_map = { - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'binding_parameters': {'key': 'bindingParameters', 'type': '{object}'}, - 'generated_properties': {'key': 'generatedProperties', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'str'}, - 'updated_at': {'key': 'updatedAt', 'type': 'str'}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "binding_parameters": {"key": "bindingParameters", "type": "{object}"}, + "generated_properties": {"key": "generatedProperties", "type": "str"}, + "created_at": {"key": "createdAt", "type": "str"}, + "updated_at": {"key": "updatedAt", "type": "str"}, } def __init__( @@ -480,7 +457,7 @@ def __init__( *, resource_id: Optional[str] = None, key: Optional[str] = None, - binding_parameters: Optional[Dict[str, Any]] = None, + binding_parameters: Optional[Dict[str, JSON]] = None, **kwargs ): """ @@ -489,9 +466,9 @@ def __init__( :keyword key: The key of the bound resource. :paramtype key: str :keyword binding_parameters: Binding parameters of the Binding resource. - :paramtype binding_parameters: dict[str, any] + :paramtype binding_parameters: dict[str, JSON] """ - super(BindingResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_name = None self.resource_type = None self.resource_id = resource_id @@ -502,7 +479,7 @@ def __init__( self.updated_at = None -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """Certificate resource payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -511,9 +488,9 @@ class CertificateProperties(msrest.serialization.Model): :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str - :ivar vault_uri: Required. The vault uri of user key vault. + :ivar vault_uri: The vault uri of user key vault. Required. :vartype vault_uri: str - :ivar key_vault_cert_name: Required. The certificate name of key vault. + :ivar key_vault_cert_name: The certificate name of key vault. Required. :vartype key_vault_cert_name: str :ivar cert_version: The certificate version of key vault. :vartype cert_version: str @@ -532,47 +509,40 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'thumbprint': {'readonly': True}, - 'vault_uri': {'required': True}, - 'key_vault_cert_name': {'required': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, - } - - _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'vault_uri': {'key': 'vaultUri', 'type': 'str'}, - 'key_vault_cert_name': {'key': 'keyVaultCertName', 'type': 'str'}, - 'cert_version': {'key': 'certVersion', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, + "thumbprint": {"readonly": True}, + "vault_uri": {"required": True}, + "key_vault_cert_name": {"required": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, } - def __init__( - self, - *, - vault_uri: str, - key_vault_cert_name: str, - cert_version: Optional[str] = None, - **kwargs - ): + _attribute_map = { + "thumbprint": {"key": "thumbprint", "type": "str"}, + "vault_uri": {"key": "vaultUri", "type": "str"}, + "key_vault_cert_name": {"key": "keyVaultCertName", "type": "str"}, + "cert_version": {"key": "certVersion", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + } + + def __init__(self, *, vault_uri: str, key_vault_cert_name: str, cert_version: Optional[str] = None, **kwargs): """ - :keyword vault_uri: Required. The vault uri of user key vault. + :keyword vault_uri: The vault uri of user key vault. Required. :paramtype vault_uri: str - :keyword key_vault_cert_name: Required. The certificate name of key vault. + :keyword key_vault_cert_name: The certificate name of key vault. Required. :paramtype key_vault_cert_name: str :keyword cert_version: The certificate version of key vault. :paramtype cert_version: str """ - super(CertificateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = None self.vault_uri = vault_uri self.key_vault_cert_name = key_vault_cert_name @@ -601,33 +571,28 @@ class CertificateResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "CertificateProperties"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: Properties of the certificate resource payload. :paramtype properties: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateProperties """ - super(CertificateResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CertificateResourceCollection(msrest.serialization.Model): +class CertificateResourceCollection(_serialization.Model): """Collection compose of certificate resources list and a possible link for next page. :ivar value: The certificate resources list. @@ -637,16 +602,12 @@ class CertificateResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CertificateResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CertificateResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CertificateResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The certificate resources list. @@ -654,12 +615,12 @@ def __init__( :keyword next_link: The link to next page of certificate list. :paramtype next_link: str """ - super(CertificateResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -676,10 +637,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -688,7 +649,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -704,21 +665,20 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.appplatform.v2021_06_01_preview.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class ClusterResourceProperties(msrest.serialization.Model): +class ClusterResourceProperties(_serialization.Model): """Service properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Provisioning state of the Service. Possible values include: - "Creating", "Updating", "Deleting", "Deleted", "Succeeded", "Failed", "Moving", "Moved", - "MoveFailed". + :ivar provisioning_state: Provisioning state of the Service. Known values are: "Creating", + "Updating", "Deleting", "Deleted", "Succeeded", "Failed", "Moving", "Moved", and "MoveFailed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.ProvisioningState :ivar network_profile: Network profile of the Service. @@ -730,36 +690,31 @@ class ClusterResourceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'version': {'readonly': True}, - 'service_id': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "service_id": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'network_profile': {'key': 'networkProfile', 'type': 'NetworkProfile'}, - 'version': {'key': 'version', 'type': 'int'}, - 'service_id': {'key': 'serviceId', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "network_profile": {"key": "networkProfile", "type": "NetworkProfile"}, + "version": {"key": "version", "type": "int"}, + "service_id": {"key": "serviceId", "type": "str"}, } - def __init__( - self, - *, - network_profile: Optional["NetworkProfile"] = None, - **kwargs - ): + def __init__(self, *, network_profile: Optional["_models.NetworkProfile"] = None, **kwargs): """ :keyword network_profile: Network profile of the Service. :paramtype network_profile: ~azure.mgmt.appplatform.v2021_06_01_preview.models.NetworkProfile """ - super(ClusterResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.network_profile = network_profile self.version = None self.service_id = None -class ConfigServerGitProperty(msrest.serialization.Model): +class ConfigServerGitProperty(_serialization.Model): """Property of git. All required parameters must be populated in order to send to Azure. @@ -767,7 +722,7 @@ class ConfigServerGitProperty(msrest.serialization.Model): :ivar repositories: Repositories of git. :vartype repositories: list[~azure.mgmt.appplatform.v2021_06_01_preview.models.GitPatternRepository] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -788,27 +743,27 @@ class ConfigServerGitProperty(msrest.serialization.Model): """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'repositories': {'key': 'repositories', 'type': '[GitPatternRepository]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "repositories": {"key": "repositories", "type": "[GitPatternRepository]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( self, *, uri: str, - repositories: Optional[List["GitPatternRepository"]] = None, + repositories: Optional[List["_models.GitPatternRepository"]] = None, label: Optional[str] = None, search_paths: Optional[List[str]] = None, username: Optional[str] = None, @@ -823,7 +778,7 @@ def __init__( :keyword repositories: Repositories of git. :paramtype repositories: list[~azure.mgmt.appplatform.v2021_06_01_preview.models.GitPatternRepository] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -842,7 +797,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(ConfigServerGitProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.repositories = repositories self.uri = uri self.label = label @@ -855,13 +810,13 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ConfigServerProperties(msrest.serialization.Model): +class ConfigServerProperties(_serialization.Model): """Config server git properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the config server. Possible values include: "NotAvailable", - "Deleted", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the config server. Known values are: "NotAvailable", + "Deleted", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerState :ivar error: Error when apply config server settings. @@ -871,20 +826,20 @@ class ConfigServerProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'config_server': {'key': 'configServer', 'type': 'ConfigServerSettings'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "config_server": {"key": "configServer", "type": "ConfigServerSettings"}, } def __init__( self, *, - error: Optional["Error"] = None, - config_server: Optional["ConfigServerSettings"] = None, + error: Optional["_models.Error"] = None, + config_server: Optional["_models.ConfigServerSettings"] = None, **kwargs ): """ @@ -894,7 +849,7 @@ def __init__( :paramtype config_server: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerSettings """ - super(ConfigServerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.config_server = config_server @@ -916,34 +871,29 @@ class ConfigServerResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ConfigServerProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ConfigServerProperties"}, } - def __init__( - self, - *, - properties: Optional["ConfigServerProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ConfigServerProperties"] = None, **kwargs): """ :keyword properties: Properties of the Config Server resource. :paramtype properties: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerProperties """ - super(ConfigServerResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ConfigServerSettings(msrest.serialization.Model): +class ConfigServerSettings(_serialization.Model): """The settings of config server. :ivar git_property: Property of git environment. @@ -952,25 +902,20 @@ class ConfigServerSettings(msrest.serialization.Model): """ _attribute_map = { - 'git_property': {'key': 'gitProperty', 'type': 'ConfigServerGitProperty'}, + "git_property": {"key": "gitProperty", "type": "ConfigServerGitProperty"}, } - def __init__( - self, - *, - git_property: Optional["ConfigServerGitProperty"] = None, - **kwargs - ): + def __init__(self, *, git_property: Optional["_models.ConfigServerGitProperty"] = None, **kwargs): """ :keyword git_property: Property of git environment. :paramtype git_property: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerGitProperty """ - super(ConfigServerSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property = git_property -class ConfigServerSettingsErrorRecord(msrest.serialization.Model): +class ConfigServerSettingsErrorRecord(_serialization.Model): """Error record of the config server settings. :ivar name: The name of the config server settings error record. @@ -982,18 +927,13 @@ class ConfigServerSettingsErrorRecord(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'messages': {'key': 'messages', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, } def __init__( - self, - *, - name: Optional[str] = None, - uri: Optional[str] = None, - messages: Optional[List[str]] = None, - **kwargs + self, *, name: Optional[str] = None, uri: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs ): """ :keyword name: The name of the config server settings error record. @@ -1003,13 +943,13 @@ def __init__( :keyword messages: The detail error messages of the record. :paramtype messages: list[str] """ - super(ConfigServerSettingsErrorRecord, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.uri = uri self.messages = messages -class ConfigServerSettingsValidateResult(msrest.serialization.Model): +class ConfigServerSettingsValidateResult(_serialization.Model): """Validation result for config server settings. :ivar is_valid: Indicate if the config server settings are valid. @@ -1020,15 +960,15 @@ class ConfigServerSettingsValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'details': {'key': 'details', 'type': '[ConfigServerSettingsErrorRecord]'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "details": {"key": "details", "type": "[ConfigServerSettingsErrorRecord]"}, } def __init__( self, *, is_valid: Optional[bool] = None, - details: Optional[List["ConfigServerSettingsErrorRecord"]] = None, + details: Optional[List["_models.ConfigServerSettingsErrorRecord"]] = None, **kwargs ): """ @@ -1038,12 +978,12 @@ def __init__( :paramtype details: list[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerSettingsErrorRecord] """ - super(ConfigServerSettingsValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.details = details -class CustomContainer(msrest.serialization.Model): +class CustomContainer(_serialization.Model): """Custom container payload. :ivar server: The name of the registry that contains the container image. @@ -1063,11 +1003,11 @@ class CustomContainer(msrest.serialization.Model): """ _attribute_map = { - 'server': {'key': 'server', 'type': 'str'}, - 'container_image': {'key': 'containerImage', 'type': 'str'}, - 'command': {'key': 'command', 'type': '[str]'}, - 'args': {'key': 'args', 'type': '[str]'}, - 'image_registry_credential': {'key': 'imageRegistryCredential', 'type': 'ImageRegistryCredential'}, + "server": {"key": "server", "type": "str"}, + "container_image": {"key": "containerImage", "type": "str"}, + "command": {"key": "command", "type": "[str]"}, + "args": {"key": "args", "type": "[str]"}, + "image_registry_credential": {"key": "imageRegistryCredential", "type": "ImageRegistryCredential"}, } def __init__( @@ -1077,7 +1017,7 @@ def __init__( container_image: Optional[str] = None, command: Optional[List[str]] = None, args: Optional[List[str]] = None, - image_registry_credential: Optional["ImageRegistryCredential"] = None, + image_registry_credential: Optional["_models.ImageRegistryCredential"] = None, **kwargs ): """ @@ -1096,7 +1036,7 @@ def __init__( :paramtype image_registry_credential: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ImageRegistryCredential """ - super(CustomContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.server = server self.container_image = container_image self.command = command @@ -1104,7 +1044,7 @@ def __init__( self.image_registry_credential = image_registry_credential -class CustomDomainProperties(msrest.serialization.Model): +class CustomDomainProperties(_serialization.Model): """Custom domain of app resource payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1118,29 +1058,23 @@ class CustomDomainProperties(msrest.serialization.Model): """ _validation = { - 'app_name': {'readonly': True}, + "app_name": {"readonly": True}, } _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'app_name': {'key': 'appName', 'type': 'str'}, - 'cert_name': {'key': 'certName', 'type': 'str'}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "app_name": {"key": "appName", "type": "str"}, + "cert_name": {"key": "certName", "type": "str"}, } - def __init__( - self, - *, - thumbprint: Optional[str] = None, - cert_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, thumbprint: Optional[str] = None, cert_name: Optional[str] = None, **kwargs): """ :keyword thumbprint: The thumbprint of bound certificate. :paramtype thumbprint: str :keyword cert_name: The bound certificate name of domain. :paramtype cert_name: str """ - super(CustomDomainProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = thumbprint self.app_name = None self.cert_name = cert_name @@ -1162,34 +1096,29 @@ class CustomDomainResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'CustomDomainProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "CustomDomainProperties"}, } - def __init__( - self, - *, - properties: Optional["CustomDomainProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CustomDomainProperties"] = None, **kwargs): """ :keyword properties: Properties of the custom domain resource. :paramtype properties: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainProperties """ - super(CustomDomainResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CustomDomainResourceCollection(msrest.serialization.Model): +class CustomDomainResourceCollection(_serialization.Model): """Collection compose of a custom domain resources list and a possible link for next page. :ivar value: The custom domain resources list. @@ -1199,16 +1128,12 @@ class CustomDomainResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CustomDomainResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CustomDomainResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The custom domain resources list. @@ -1216,43 +1141,38 @@ def __init__( :keyword next_link: The link to next page of custom domain list. :paramtype next_link: str """ - super(CustomDomainResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CustomDomainValidatePayload(msrest.serialization.Model): +class CustomDomainValidatePayload(_serialization.Model): """Custom domain validate payload. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name to be validated. + :ivar name: Name to be validated. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Name to be validated. + :keyword name: Name to be validated. Required. :paramtype name: str """ - super(CustomDomainValidatePayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CustomDomainValidateResult(msrest.serialization.Model): +class CustomDomainValidateResult(_serialization.Model): """Validation result for custom domain. :ivar is_valid: Indicates if domain name is valid. @@ -1262,29 +1182,23 @@ class CustomDomainValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'message': {'key': 'message', 'type': 'str'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - is_valid: Optional[bool] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, is_valid: Optional[bool] = None, message: Optional[str] = None, **kwargs): """ :keyword is_valid: Indicates if domain name is valid. :paramtype is_valid: bool :keyword message: Message of why domain name is invalid. :paramtype message: str """ - super(CustomDomainValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.message = message -class DeploymentInstance(msrest.serialization.Model): +class DeploymentInstance(_serialization.Model): """Deployment instance payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1302,28 +1216,24 @@ class DeploymentInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, - 'reason': {'readonly': True}, - 'discovery_status': {'readonly': True}, - 'start_time': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, + "reason": {"readonly": True}, + "discovery_status": {"readonly": True}, + "start_time": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'discovery_status': {'key': 'discoveryStatus', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "discovery_status": {"key": "discoveryStatus", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None self.reason = None @@ -1350,24 +1260,24 @@ class DeploymentResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( self, *, - properties: Optional["DeploymentResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.DeploymentResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -1377,12 +1287,12 @@ def __init__( :keyword sku: Sku of the Deployment resource. :paramtype sku: ~azure.mgmt.appplatform.v2021_06_01_preview.models.Sku """ - super(DeploymentResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.sku = sku -class DeploymentResourceCollection(msrest.serialization.Model): +class DeploymentResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of Deployment resources. @@ -1393,16 +1303,12 @@ class DeploymentResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["DeploymentResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.DeploymentResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Deployment resources. @@ -1411,12 +1317,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(DeploymentResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class DeploymentResourceProperties(msrest.serialization.Model): +class DeploymentResourceProperties(_serialization.Model): """Deployment resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1428,12 +1334,12 @@ class DeploymentResourceProperties(msrest.serialization.Model): :ivar deployment_settings: Deployment settings of the Deployment. :vartype deployment_settings: ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentSettings - :ivar provisioning_state: Provisioning state of the Deployment. Possible values include: - "Creating", "Updating", "Succeeded", "Failed". + :ivar provisioning_state: Provisioning state of the Deployment. Known values are: "Creating", + "Updating", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResourceProvisioningState - :ivar status: Status of the Deployment. Possible values include: "Unknown", "Stopped", - "Running", "Failed", "Allocating", "Upgrading", "Compiling". + :ivar status: Status of the Deployment. Known values are: "Unknown", "Stopped", "Running", + "Failed", "Allocating", "Upgrading", and "Compiling". :vartype status: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResourceStatus :ivar active: Indicates whether the Deployment is active. @@ -1445,30 +1351,30 @@ class DeploymentResourceProperties(msrest.serialization.Model): """ _validation = { - 'app_name': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'active': {'readonly': True}, - 'created_time': {'readonly': True}, - 'instances': {'readonly': True}, + "app_name": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "active": {"readonly": True}, + "created_time": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'UserSourceInfo'}, - 'app_name': {'key': 'appName', 'type': 'str'}, - 'deployment_settings': {'key': 'deploymentSettings', 'type': 'DeploymentSettings'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'active': {'key': 'active', 'type': 'bool'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'instances': {'key': 'instances', 'type': '[DeploymentInstance]'}, + "source": {"key": "source", "type": "UserSourceInfo"}, + "app_name": {"key": "appName", "type": "str"}, + "deployment_settings": {"key": "deploymentSettings", "type": "DeploymentSettings"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "active": {"key": "active", "type": "bool"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "instances": {"key": "instances", "type": "[DeploymentInstance]"}, } def __init__( self, *, - source: Optional["UserSourceInfo"] = None, - deployment_settings: Optional["DeploymentSettings"] = None, + source: Optional["_models.UserSourceInfo"] = None, + deployment_settings: Optional["_models.DeploymentSettings"] = None, **kwargs ): """ @@ -1478,7 +1384,7 @@ def __init__( :paramtype deployment_settings: ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentSettings """ - super(DeploymentResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.app_name = None self.deployment_settings = deployment_settings @@ -1489,7 +1395,7 @@ def __init__( self.instances = None -class DeploymentSettings(msrest.serialization.Model): +class DeploymentSettings(_serialization.Model): """Deployment settings payload. :ivar cpu: Required CPU. This should be 1 for Basic tier, and in range [1, 4] for Standard @@ -1510,32 +1416,32 @@ class DeploymentSettings(msrest.serialization.Model): :vartype net_core_main_entry_path: str :ivar environment_variables: Collection of environment variables. :vartype environment_variables: dict[str, str] - :ivar runtime_version: Runtime version. Possible values include: "Java_8", "Java_11", - "NetCore_31". Default value: "Java_8". + :ivar runtime_version: Runtime version. Known values are: "Java_8", "Java_11", and + "NetCore_31". :vartype runtime_version: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.RuntimeVersion """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'int'}, - 'memory_in_gb': {'key': 'memoryInGB', 'type': 'int'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'ResourceRequests'}, - 'jvm_options': {'key': 'jvmOptions', 'type': 'str'}, - 'net_core_main_entry_path': {'key': 'netCoreMainEntryPath', 'type': 'str'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '{str}'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "int"}, + "memory_in_gb": {"key": "memoryInGB", "type": "int"}, + "resource_requests": {"key": "resourceRequests", "type": "ResourceRequests"}, + "jvm_options": {"key": "jvmOptions", "type": "str"}, + "net_core_main_entry_path": {"key": "netCoreMainEntryPath", "type": "str"}, + "environment_variables": {"key": "environmentVariables", "type": "{str}"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, } def __init__( self, *, - cpu: Optional[int] = 1, - memory_in_gb: Optional[int] = 1, - resource_requests: Optional["ResourceRequests"] = None, + cpu: int = 1, + memory_in_gb: int = 1, + resource_requests: Optional["_models.ResourceRequests"] = None, jvm_options: Optional[str] = None, net_core_main_entry_path: Optional[str] = None, environment_variables: Optional[Dict[str, str]] = None, - runtime_version: Optional[Union[str, "RuntimeVersion"]] = "Java_8", + runtime_version: Union[str, "_models.RuntimeVersion"] = "Java_8", **kwargs ): """ @@ -1558,12 +1464,12 @@ def __init__( :paramtype net_core_main_entry_path: str :keyword environment_variables: Collection of environment variables. :paramtype environment_variables: dict[str, str] - :keyword runtime_version: Runtime version. Possible values include: "Java_8", "Java_11", - "NetCore_31". Default value: "Java_8". + :keyword runtime_version: Runtime version. Known values are: "Java_8", "Java_11", and + "NetCore_31". :paramtype runtime_version: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.RuntimeVersion """ - super(DeploymentSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory_in_gb = memory_in_gb self.resource_requests = resource_requests @@ -1573,7 +1479,7 @@ def __init__( self.runtime_version = runtime_version -class Error(msrest.serialization.Model): +class Error(_serialization.Model): """The error code compose of code and message. :ivar code: The code of error. @@ -1583,38 +1489,32 @@ class Error(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: The code of error. :paramtype code: str :keyword message: The message of error. :paramtype message: str """ - super(Error, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class GitPatternRepository(msrest.serialization.Model): +class GitPatternRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes """Git repository property payload. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the repository. + :ivar name: Name of the repository. Required. :vartype name: str :ivar pattern: Collection of pattern of the repository. :vartype pattern: list[str] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -1635,22 +1535,22 @@ class GitPatternRepository(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'uri': {'required': True}, + "name": {"required": True}, + "uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'pattern': {'key': 'pattern', 'type': '[str]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "pattern": {"key": "pattern", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( @@ -1670,11 +1570,11 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of the repository. + :keyword name: Name of the repository. Required. :paramtype name: str :keyword pattern: Collection of pattern of the repository. :paramtype pattern: list[str] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -1693,7 +1593,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(GitPatternRepository, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.pattern = pattern self.uri = uri @@ -1707,7 +1607,7 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ImageRegistryCredential(msrest.serialization.Model): +class ImageRegistryCredential(_serialization.Model): """Credential of the image registry. :ivar username: The username of the image registry credential. @@ -1717,60 +1617,49 @@ class ImageRegistryCredential(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - username: Optional[str] = None, - password: Optional[str] = None, - **kwargs - ): + def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs): """ :keyword username: The username of the image registry credential. :paramtype username: str :keyword password: The password of the image registry credential. :paramtype password: str """ - super(ImageRegistryCredential, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.password = password -class LogFileUrlResponse(msrest.serialization.Model): +class LogFileUrlResponse(_serialization.Model): """Log file URL payload. All required parameters must be populated in order to send to Azure. - :ivar url: Required. URL of the log file. + :ivar url: URL of the log file. Required. :vartype url: str """ _validation = { - 'url': {'required': True}, + "url": {"required": True}, } _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, } - def __init__( - self, - *, - url: str, - **kwargs - ): + def __init__(self, *, url: str, **kwargs): """ - :keyword url: Required. URL of the log file. + :keyword url: URL of the log file. Required. :paramtype url: str """ - super(LogFileUrlResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url -class LogSpecification(msrest.serialization.Model): +class LogSpecification(_serialization.Model): """Specifications of the Log for Azure Monitoring. :ivar name: Name of the log. @@ -1782,9 +1671,9 @@ class LogSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, } def __init__( @@ -1803,17 +1692,17 @@ def __init__( :keyword blob_duration: Blob duration of the log. :paramtype blob_duration: str """ - super(LogSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class ManagedIdentityProperties(msrest.serialization.Model): +class ManagedIdentityProperties(_serialization.Model): """Managed identity properties retrieved from ARM request headers. - :ivar type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.ManagedIdentityType :ivar principal_id: Principal Id. :vartype principal_id: str @@ -1822,35 +1711,35 @@ class ManagedIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ManagedIdentityType"]] = None, + type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs ): """ - :keyword type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.ManagedIdentityType :keyword principal_id: Principal Id. :paramtype principal_id: str :keyword tenant_id: Tenant Id. :paramtype tenant_id: str """ - super(ManagedIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.principal_id = principal_id self.tenant_id = tenant_id -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """Specifications of the Dimension of metrics. :ivar name: Name of the dimension. @@ -1863,9 +1752,9 @@ class MetricDimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -1885,13 +1774,13 @@ def __init__( export scenario. :paramtype to_be_exported_for_shoebox: bool """ - super(MetricDimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes """Specifications of the Metrics for Azure Monitoring. :ivar name: Name of the metric. @@ -1922,17 +1811,17 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "source_mdm_namespace": {"key": "sourceMdmNamespace", "type": "str"}, } def __init__( @@ -1947,7 +1836,7 @@ def __init__( supported_aggregation_types: Optional[List[str]] = None, supported_time_grain_types: Optional[List[str]] = None, fill_gap_with_zero: Optional[bool] = None, - dimensions: Optional[List["MetricDimension"]] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, source_mdm_namespace: Optional[str] = None, **kwargs ): @@ -1978,7 +1867,7 @@ def __init__( :keyword source_mdm_namespace: Name of the MDM namespace. Optional. :paramtype source_mdm_namespace: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1992,13 +1881,13 @@ def __init__( self.source_mdm_namespace = source_mdm_namespace -class MonitoringSettingProperties(msrest.serialization.Model): +class MonitoringSettingProperties(_serialization.Model): """Monitoring Setting properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Monitoring Setting. Possible values include: - "NotAvailable", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the Monitoring Setting. Known values are: "NotAvailable", + "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingState :ivar error: Error when apply Monitoring Setting changes. @@ -2019,27 +1908,27 @@ class MonitoringSettingProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'app_insights_sampling_rate': {'maximum': 100, 'minimum': 0}, + "provisioning_state": {"readonly": True}, + "app_insights_sampling_rate": {"maximum": 100, "minimum": 0}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'trace_enabled': {'key': 'traceEnabled', 'type': 'bool'}, - 'app_insights_instrumentation_key': {'key': 'appInsightsInstrumentationKey', 'type': 'str'}, - 'app_insights_sampling_rate': {'key': 'appInsightsSamplingRate', 'type': 'float'}, - 'app_insights_agent_versions': {'key': 'appInsightsAgentVersions', 'type': 'ApplicationInsightsAgentVersions'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "trace_enabled": {"key": "traceEnabled", "type": "bool"}, + "app_insights_instrumentation_key": {"key": "appInsightsInstrumentationKey", "type": "str"}, + "app_insights_sampling_rate": {"key": "appInsightsSamplingRate", "type": "float"}, + "app_insights_agent_versions": {"key": "appInsightsAgentVersions", "type": "ApplicationInsightsAgentVersions"}, } def __init__( self, *, - error: Optional["Error"] = None, + error: Optional["_models.Error"] = None, trace_enabled: Optional[bool] = None, app_insights_instrumentation_key: Optional[str] = None, app_insights_sampling_rate: Optional[float] = None, - app_insights_agent_versions: Optional["ApplicationInsightsAgentVersions"] = None, + app_insights_agent_versions: Optional["_models.ApplicationInsightsAgentVersions"] = None, **kwargs ): """ @@ -2059,7 +1948,7 @@ def __init__( :paramtype app_insights_agent_versions: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ApplicationInsightsAgentVersions """ - super(MonitoringSettingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.trace_enabled = trace_enabled @@ -2085,34 +1974,29 @@ class MonitoringSettingResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'MonitoringSettingProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "MonitoringSettingProperties"}, } - def __init__( - self, - *, - properties: Optional["MonitoringSettingProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.MonitoringSettingProperties"] = None, **kwargs): """ :keyword properties: Properties of the Monitoring Setting resource. :paramtype properties: ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingProperties """ - super(MonitoringSettingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class NameAvailability(msrest.serialization.Model): +class NameAvailability(_serialization.Model): """Name availability result payload. :ivar name_available: Indicates whether the name is available. @@ -2124,9 +2008,9 @@ class NameAvailability(msrest.serialization.Model): """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } def __init__( @@ -2145,52 +2029,46 @@ def __init__( :keyword message: Message why the name is not available. :paramtype message: str """ - super(NameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class NameAvailabilityParameters(msrest.serialization.Model): +class NameAvailabilityParameters(_serialization.Model): """Name availability parameters payload. All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the resource to check name availability. + :ivar type: Type of the resource to check name availability. Required. :vartype type: str - :ivar name: Required. Name to be checked. + :ivar name: Name to be checked. Required. :vartype name: str """ _validation = { - 'type': {'required': True}, - 'name': {'required': True}, + "type": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - type: str, - name: str, - **kwargs - ): + def __init__(self, *, type: str, name: str, **kwargs): """ - :keyword type: Required. Type of the resource to check name availability. + :keyword type: Type of the resource to check name availability. Required. :paramtype type: str - :keyword name: Required. Name to be checked. + :keyword name: Name to be checked. Required. :paramtype name: str """ - super(NameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class NetworkProfile(msrest.serialization.Model): +class NetworkProfile(_serialization.Model): """Service network profile payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2217,18 +2095,18 @@ class NetworkProfile(msrest.serialization.Model): """ _validation = { - 'outbound_i_ps': {'readonly': True}, - 'required_traffics': {'readonly': True}, + "outbound_i_ps": {"readonly": True}, + "required_traffics": {"readonly": True}, } _attribute_map = { - 'service_runtime_subnet_id': {'key': 'serviceRuntimeSubnetId', 'type': 'str'}, - 'app_subnet_id': {'key': 'appSubnetId', 'type': 'str'}, - 'service_cidr': {'key': 'serviceCidr', 'type': 'str'}, - 'service_runtime_network_resource_group': {'key': 'serviceRuntimeNetworkResourceGroup', 'type': 'str'}, - 'app_network_resource_group': {'key': 'appNetworkResourceGroup', 'type': 'str'}, - 'outbound_i_ps': {'key': 'outboundIPs', 'type': 'NetworkProfileOutboundIPs'}, - 'required_traffics': {'key': 'requiredTraffics', 'type': '[RequiredTraffic]'}, + "service_runtime_subnet_id": {"key": "serviceRuntimeSubnetId", "type": "str"}, + "app_subnet_id": {"key": "appSubnetId", "type": "str"}, + "service_cidr": {"key": "serviceCidr", "type": "str"}, + "service_runtime_network_resource_group": {"key": "serviceRuntimeNetworkResourceGroup", "type": "str"}, + "app_network_resource_group": {"key": "appNetworkResourceGroup", "type": "str"}, + "outbound_i_ps": {"key": "outboundIPs", "type": "NetworkProfileOutboundIPs"}, + "required_traffics": {"key": "requiredTraffics", "type": "[RequiredTraffic]"}, } def __init__( @@ -2257,7 +2135,7 @@ def __init__( Azure Spring Cloud Apps. :paramtype app_network_resource_group: str """ - super(NetworkProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_runtime_subnet_id = service_runtime_subnet_id self.app_subnet_id = app_subnet_id self.service_cidr = service_cidr @@ -2267,7 +2145,7 @@ def __init__( self.required_traffics = None -class NetworkProfileOutboundIPs(msrest.serialization.Model): +class NetworkProfileOutboundIPs(_serialization.Model): """Desired outbound IP resources for Azure Spring Cloud instance. Variables are only populated by the server, and will be ignored when sending a request. @@ -2277,24 +2155,20 @@ class NetworkProfileOutboundIPs(msrest.serialization.Model): """ _validation = { - 'public_i_ps': {'readonly': True}, + "public_i_ps": {"readonly": True}, } _attribute_map = { - 'public_i_ps': {'key': 'publicIPs', 'type': '[str]'}, + "public_i_ps": {"key": "publicIPs", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(NetworkProfileOutboundIPs, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.public_i_ps = None -class OperationDetail(msrest.serialization.Model): +class OperationDetail(_serialization.Model): """Operation detail payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2306,7 +2180,7 @@ class OperationDetail(msrest.serialization.Model): :ivar display: Display of the operation. :vartype display: ~azure.mgmt.appplatform.v2021_06_01_preview.models.OperationDisplay :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. Possible values include: "Internal". + internal only APIs. "Internal" :vartype action_type: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.ActionType :ivar origin: Origin of the operation. :vartype origin: str @@ -2315,16 +2189,16 @@ class OperationDetail(msrest.serialization.Model): """ _validation = { - 'action_type': {'readonly': True}, + "action_type": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'action_type': {'key': 'actionType', 'type': 'str'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "action_type": {"key": "actionType", "type": "str"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "OperationProperties"}, } def __init__( @@ -2332,9 +2206,9 @@ 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, - properties: Optional["OperationProperties"] = None, + properties: Optional["_models.OperationProperties"] = None, **kwargs ): """ @@ -2349,7 +2223,7 @@ def __init__( :keyword properties: Properties of the operation. :paramtype properties: ~azure.mgmt.appplatform.v2021_06_01_preview.models.OperationProperties """ - super(OperationDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display @@ -2358,7 +2232,7 @@ def __init__( self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display payload. :ivar provider: Resource provider of the operation. @@ -2372,10 +2246,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__( @@ -2397,14 +2271,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 OperationProperties(msrest.serialization.Model): +class OperationProperties(_serialization.Model): """Extra Operation properties. :ivar service_specification: Service specifications of the operation. @@ -2413,25 +2287,20 @@ class OperationProperties(msrest.serialization.Model): """ _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, } - def __init__( - self, - *, - service_specification: Optional["ServiceSpecification"] = None, - **kwargs - ): + def __init__(self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs): """ :keyword service_specification: Service specifications of the operation. :paramtype service_specification: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceSpecification """ - super(OperationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_specification = service_specification -class PersistentDisk(msrest.serialization.Model): +class PersistentDisk(_serialization.Model): """Persistent disk payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2445,69 +2314,56 @@ class PersistentDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 50, 'minimum': 0}, - 'used_in_gb': {'readonly': True, 'maximum': 50, 'minimum': 0}, + "size_in_gb": {"maximum": 50, "minimum": 0}, + "used_in_gb": {"readonly": True, "maximum": 50, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'used_in_gb': {'key': 'usedInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "used_in_gb": {"key": "usedInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: Optional[str] = None, **kwargs): """ :keyword size_in_gb: Size of the persistent disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the persistent disk. :paramtype mount_path: str """ - super(PersistentDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.used_in_gb = None self.mount_path = mount_path -class RegenerateTestKeyRequestPayload(msrest.serialization.Model): +class RegenerateTestKeyRequestPayload(_serialization.Model): """Regenerate test key request payload. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :ivar key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :vartype key_type: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.TestKeyType """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "TestKeyType"], - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.TestKeyType"], **kwargs): """ - :keyword key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :keyword key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :paramtype key_type: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.TestKeyType """ - super(RegenerateTestKeyRequestPayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type -class RequiredTraffic(msrest.serialization.Model): +class RequiredTraffic(_serialization.Model): """Required inbound or outbound traffic for Azure Spring Cloud instance. Variables are only populated by the server, and will be ignored when sending a request. @@ -2520,34 +2376,29 @@ class RequiredTraffic(msrest.serialization.Model): :vartype ips: list[str] :ivar fqdns: The FQDN list of required traffic. :vartype fqdns: list[str] - :ivar direction: The direction of required traffic. Possible values include: "Inbound", - "Outbound". + :ivar direction: The direction of required traffic. Known values are: "Inbound" and "Outbound". :vartype direction: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.TrafficDirection """ _validation = { - 'protocol': {'readonly': True}, - 'port': {'readonly': True}, - 'ips': {'readonly': True}, - 'fqdns': {'readonly': True}, - 'direction': {'readonly': True}, + "protocol": {"readonly": True}, + "port": {"readonly": True}, + "ips": {"readonly": True}, + "fqdns": {"readonly": True}, + "direction": {"readonly": True}, } _attribute_map = { - 'protocol': {'key': 'protocol', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - 'ips': {'key': 'ips', 'type': '[str]'}, - 'fqdns': {'key': 'fqdns', 'type': '[str]'}, - 'direction': {'key': 'direction', 'type': 'str'}, + "protocol": {"key": "protocol", "type": "str"}, + "port": {"key": "port", "type": "int"}, + "ips": {"key": "ips", "type": "[str]"}, + "fqdns": {"key": "fqdns", "type": "[str]"}, + "direction": {"key": "direction", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RequiredTraffic, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.protocol = None self.port = None self.ips = None @@ -2555,7 +2406,7 @@ def __init__( self.direction = None -class ResourceRequests(msrest.serialization.Model): +class ResourceRequests(_serialization.Model): """Deployment resource request payload. :ivar cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 for @@ -2567,17 +2418,11 @@ class ResourceRequests(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - *, - cpu: Optional[str] = None, - memory: Optional[str] = None, - **kwargs - ): + def __init__(self, *, cpu: Optional[str] = None, memory: Optional[str] = None, **kwargs): """ :keyword cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 for Basic tier, and {500m, 1, 2, 3, 4} for Standard tier. @@ -2586,12 +2431,12 @@ def __init__( {512Mi, 1Gi, 2Gi} for Basic tier, and {512Mi, 1Gi, 2Gi, ..., 8Gi} for Standard tier. :paramtype memory: str """ - super(ResourceRequests, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory = memory -class ResourceSku(msrest.serialization.Model): +class ResourceSku(_serialization.Model): """Describes an available Azure Spring Cloud SKU. :ivar resource_type: Gets the type of resource the SKU applies to. @@ -2615,13 +2460,13 @@ class ResourceSku(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'SkuCapacity'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[ResourceSkuLocationInfo]'}, - 'restrictions': {'key': 'restrictions', 'type': '[ResourceSkuRestrictions]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "SkuCapacity"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[ResourceSkuLocationInfo]"}, + "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, } def __init__( @@ -2630,10 +2475,10 @@ def __init__( resource_type: Optional[str] = None, name: Optional[str] = None, tier: Optional[str] = None, - capacity: Optional["SkuCapacity"] = None, + capacity: Optional["_models.SkuCapacity"] = None, locations: Optional[List[str]] = None, - location_info: Optional[List["ResourceSkuLocationInfo"]] = None, - restrictions: Optional[List["ResourceSkuRestrictions"]] = None, + location_info: Optional[List["_models.ResourceSkuLocationInfo"]] = None, + restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None, **kwargs ): """ @@ -2656,7 +2501,7 @@ def __init__( :paramtype restrictions: list[~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceSkuRestrictions] """ - super(ResourceSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.name = name self.tier = tier @@ -2666,7 +2511,7 @@ def __init__( self.restrictions = restrictions -class ResourceSkuCapabilities(msrest.serialization.Model): +class ResourceSkuCapabilities(_serialization.Model): """ResourceSkuCapabilities. :ivar name: Gets an invariant to describe the feature. @@ -2676,29 +2521,23 @@ class ResourceSkuCapabilities(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: Gets an invariant to describe the feature. :paramtype name: str :keyword value: Gets an invariant if the feature is measured by quantity. :paramtype value: str """ - super(ResourceSkuCapabilities, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class ResourceSkuCollection(msrest.serialization.Model): +class ResourceSkuCollection(_serialization.Model): """Object that includes an array of Azure Spring Cloud SKU and a possible link for next set. :ivar value: Collection of resource SKU. @@ -2709,16 +2548,12 @@ class ResourceSkuCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ResourceSku"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ResourceSku"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of resource SKU. @@ -2727,12 +2562,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ResourceSkuCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ResourceSkuLocationInfo(msrest.serialization.Model): +class ResourceSkuLocationInfo(_serialization.Model): """Locations and availability zones where the SKU is available. :ivar location: Gets location of the SKU. @@ -2745,9 +2580,9 @@ class ResourceSkuLocationInfo(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'zone_details': {'key': 'zoneDetails', 'type': '[ResourceSkuZoneDetails]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "zone_details": {"key": "zoneDetails", "type": "[ResourceSkuZoneDetails]"}, } def __init__( @@ -2755,7 +2590,7 @@ def __init__( *, location: Optional[str] = None, zones: Optional[List[str]] = None, - zone_details: Optional[List["ResourceSkuZoneDetails"]] = None, + zone_details: Optional[List["_models.ResourceSkuZoneDetails"]] = None, **kwargs ): """ @@ -2767,13 +2602,13 @@ def __init__( :paramtype zone_details: list[~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceSkuZoneDetails] """ - super(ResourceSkuLocationInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones self.zone_details = zone_details -class ResourceSkuRestrictionInfo(msrest.serialization.Model): +class ResourceSkuRestrictionInfo(_serialization.Model): """Information about the restriction where the SKU cannot be used. :ivar locations: Gets locations where the SKU is restricted. @@ -2783,33 +2618,27 @@ class ResourceSkuRestrictionInfo(msrest.serialization.Model): """ _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - locations: Optional[List[str]] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, locations: Optional[List[str]] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword locations: Gets locations where the SKU is restricted. :paramtype locations: list[str] :keyword zones: Gets list of availability zones where the SKU is restricted. :paramtype zones: list[str] """ - super(ResourceSkuRestrictionInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.locations = locations self.zones = zones -class ResourceSkuRestrictions(msrest.serialization.Model): +class ResourceSkuRestrictions(_serialization.Model): """Restrictions where the SKU cannot be used. - :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. Known + values are: "Location" and "Zone". :vartype type: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceSkuRestrictionsType :ivar values: Gets the value of restrictions. If the restriction type is set to @@ -2820,31 +2649,30 @@ class ResourceSkuRestrictions(msrest.serialization.Model): :vartype restriction_info: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceSkuRestrictionInfo :ivar reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceSkuRestrictionsReasonCode """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'ResourceSkuRestrictionInfo'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "restriction_info": {"key": "restrictionInfo", "type": "ResourceSkuRestrictionInfo"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceSkuRestrictionsType"]] = None, + type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None, values: Optional[List[str]] = None, - restriction_info: Optional["ResourceSkuRestrictionInfo"] = None, - reason_code: Optional[Union[str, "ResourceSkuRestrictionsReasonCode"]] = None, + restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None, + reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None, **kwargs ): """ :keyword type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + Known values are: "Location" and "Zone". :paramtype type: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceSkuRestrictionsType :keyword values: Gets the value of restrictions. If the restriction type is set to @@ -2855,19 +2683,18 @@ def __init__( :paramtype restriction_info: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceSkuRestrictionInfo :keyword reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceSkuRestrictionsReasonCode """ - super(ResourceSkuRestrictions, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.values = values self.restriction_info = restriction_info self.reason_code = reason_code -class ResourceSkuZoneDetails(msrest.serialization.Model): +class ResourceSkuZoneDetails(_serialization.Model): """Details of capabilities available to a SKU in specific zones. :ivar name: Gets the set of zones that the SKU is available in with the @@ -2880,15 +2707,15 @@ class ResourceSkuZoneDetails(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[ResourceSkuCapabilities]'}, + "name": {"key": "name", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, } def __init__( self, *, name: Optional[List[str]] = None, - capabilities: Optional[List["ResourceSkuCapabilities"]] = None, + capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None, **kwargs ): """ @@ -2900,12 +2727,12 @@ def __init__( :paramtype capabilities: list[~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceSkuCapabilities] """ - super(ResourceSkuZoneDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.capabilities = capabilities -class ResourceUploadDefinition(msrest.serialization.Model): +class ResourceUploadDefinition(_serialization.Model): """Resource upload definition payload. :ivar relative_path: Source relative path. @@ -2915,24 +2742,18 @@ class ResourceUploadDefinition(msrest.serialization.Model): """ _attribute_map = { - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'upload_url': {'key': 'uploadUrl', 'type': 'str'}, + "relative_path": {"key": "relativePath", "type": "str"}, + "upload_url": {"key": "uploadUrl", "type": "str"}, } - def __init__( - self, - *, - relative_path: Optional[str] = None, - upload_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, relative_path: Optional[str] = None, upload_url: Optional[str] = None, **kwargs): """ :keyword relative_path: Source relative path. :paramtype relative_path: str :keyword upload_url: Upload URL. :paramtype upload_url: str """ - super(ResourceUploadDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.relative_path = relative_path self.upload_url = upload_url @@ -2950,40 +2771,33 @@ class TrackedResource(Resource): :vartype type: str :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -3001,8 +2815,7 @@ class ServiceResource(TrackedResource): :vartype type: str :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] :ivar properties: Properties of the Service resource. :vartype properties: @@ -3012,19 +2825,19 @@ class ServiceResource(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ClusterResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "ClusterResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( @@ -3032,15 +2845,15 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - properties: Optional["ClusterResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.ClusterResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] :keyword properties: Properties of the Service resource. :paramtype properties: @@ -3048,12 +2861,12 @@ def __init__( :keyword sku: Sku of the Service resource. :paramtype sku: ~azure.mgmt.appplatform.v2021_06_01_preview.models.Sku """ - super(ServiceResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.properties = properties self.sku = sku -class ServiceResourceList(msrest.serialization.Model): +class ServiceResourceList(_serialization.Model): """Object that includes an array of Service resources and a possible link for next set. :ivar value: Collection of Service resources. @@ -3064,16 +2877,12 @@ class ServiceResourceList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ServiceResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ServiceResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Service resources. @@ -3082,12 +2891,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ServiceResourceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification payload. :ivar log_specifications: Specifications of the Log for Azure Monitoring. @@ -3099,15 +2908,15 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } def __init__( self, *, - log_specifications: Optional[List["LogSpecification"]] = None, - metric_specifications: Optional[List["MetricSpecification"]] = None, + log_specifications: Optional[List["_models.LogSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -3118,12 +2927,12 @@ def __init__( :paramtype metric_specifications: list[~azure.mgmt.appplatform.v2021_06_01_preview.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_specifications = log_specifications self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """Sku of Azure Spring Cloud. :ivar name: Name of the Sku. @@ -3135,19 +2944,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Optional[str] = "S0", - tier: Optional[str] = "Standard", - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: str = "S0", tier: str = "Standard", capacity: Optional[int] = None, **kwargs): """ :keyword name: Name of the Sku. :paramtype name: str @@ -3156,37 +2958,37 @@ def __init__( :keyword capacity: Current capacity of the target resource. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SkuCapacity(msrest.serialization.Model): +class SkuCapacity(_serialization.Model): """The SKU capacity. All required parameters must be populated in order to send to Azure. - :ivar minimum: Required. Gets or sets the minimum. + :ivar minimum: Gets or sets the minimum. Required. :vartype minimum: int :ivar maximum: Gets or sets the maximum. :vartype maximum: int :ivar default: Gets or sets the default. :vartype default: int - :ivar scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :ivar scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", and + "Automatic". :vartype scale_type: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.SkuScaleType """ _validation = { - 'minimum': {'required': True}, + "minimum": {"required": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } def __init__( @@ -3195,35 +2997,35 @@ def __init__( minimum: int, maximum: Optional[int] = None, default: Optional[int] = None, - scale_type: Optional[Union[str, "SkuScaleType"]] = None, + scale_type: Optional[Union[str, "_models.SkuScaleType"]] = None, **kwargs ): """ - :keyword minimum: Required. Gets or sets the minimum. + :keyword minimum: Gets or sets the minimum. Required. :paramtype minimum: int :keyword maximum: Gets or sets the maximum. :paramtype maximum: int :keyword default: Gets or sets the default. :paramtype default: int - :keyword scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :keyword scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", + and "Automatic". :paramtype scale_type: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.SkuScaleType """ - super(SkuCapacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.minimum = minimum self.maximum = maximum self.default = default self.scale_type = scale_type -class SupportedRuntimeVersion(msrest.serialization.Model): +class SupportedRuntimeVersion(_serialization.Model): """Supported deployment runtime version descriptor. - :ivar value: The raw value which could be passed to deployment CRUD operations. Possible values - include: "Java_8", "Java_11", "NetCore_31". + :ivar value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", and "NetCore_31". :vartype value: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.SupportedRuntimeValue - :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). Known + values are: "Java" and ".NET Core". :vartype platform: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.SupportedRuntimePlatform :ivar version: The detailed version (major.minor) of the platform. @@ -3231,38 +3033,38 @@ class SupportedRuntimeVersion(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'platform': {'key': 'platform', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "platform": {"key": "platform", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - value: Optional[Union[str, "SupportedRuntimeValue"]] = None, - platform: Optional[Union[str, "SupportedRuntimePlatform"]] = None, + value: Optional[Union[str, "_models.SupportedRuntimeValue"]] = None, + platform: Optional[Union[str, "_models.SupportedRuntimePlatform"]] = None, version: Optional[str] = None, **kwargs ): """ - :keyword value: The raw value which could be passed to deployment CRUD operations. Possible - values include: "Java_8", "Java_11", "NetCore_31". + :keyword value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", and "NetCore_31". :paramtype value: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.SupportedRuntimeValue :keyword platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + Known values are: "Java" and ".NET Core". :paramtype platform: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.SupportedRuntimePlatform :keyword version: The detailed version (major.minor) of the platform. :paramtype version: str """ - super(SupportedRuntimeVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.platform = platform self.version = version -class TemporaryDisk(msrest.serialization.Model): +class TemporaryDisk(_serialization.Model): """Temporary disk payload. :ivar size_in_gb: Size of the temporary disk in GB. @@ -3272,33 +3074,27 @@ class TemporaryDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 5, 'minimum': 0}, + "size_in_gb": {"maximum": 5, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = "/tmp", - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: str = "/tmp", **kwargs): """ :keyword size_in_gb: Size of the temporary disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the temporary disk. :paramtype mount_path: str """ - super(TemporaryDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.mount_path = mount_path -class TestKeys(msrest.serialization.Model): +class TestKeys(_serialization.Model): """Test keys payload. :ivar primary_key: Primary key. @@ -3314,11 +3110,11 @@ class TestKeys(msrest.serialization.Model): """ _attribute_map = { - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'primary_test_endpoint': {'key': 'primaryTestEndpoint', 'type': 'str'}, - 'secondary_test_endpoint': {'key': 'secondaryTestEndpoint', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "primary_test_endpoint": {"key": "primaryTestEndpoint", "type": "str"}, + "secondary_test_endpoint": {"key": "secondaryTestEndpoint", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, } def __init__( @@ -3343,7 +3139,7 @@ def __init__( :keyword enabled: Indicates whether the test endpoint feature enabled or not. :paramtype enabled: bool """ - super(TestKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_key = primary_key self.secondary_key = secondary_key self.primary_test_endpoint = primary_test_endpoint @@ -3351,11 +3147,11 @@ def __init__( self.enabled = enabled -class UserSourceInfo(msrest.serialization.Model): +class UserSourceInfo(_serialization.Model): """Source information for a deployment. - :ivar type: Type of the source uploaded. Possible values include: "Jar", "NetCoreZip", - "Source", "Container". + :ivar type: Type of the source uploaded. Known values are: "Jar", "NetCoreZip", "Source", and + "Container". :vartype type: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.UserSourceType :ivar relative_path: Relative path of the storage which stores the source. :vartype relative_path: str @@ -3370,26 +3166,26 @@ class UserSourceInfo(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'artifact_selector': {'key': 'artifactSelector', 'type': 'str'}, - 'custom_container': {'key': 'customContainer', 'type': 'CustomContainer'}, + "type": {"key": "type", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "artifact_selector": {"key": "artifactSelector", "type": "str"}, + "custom_container": {"key": "customContainer", "type": "CustomContainer"}, } def __init__( self, *, - type: Optional[Union[str, "UserSourceType"]] = None, + type: Optional[Union[str, "_models.UserSourceType"]] = None, relative_path: Optional[str] = None, version: Optional[str] = None, artifact_selector: Optional[str] = None, - custom_container: Optional["CustomContainer"] = None, + custom_container: Optional["_models.CustomContainer"] = None, **kwargs ): """ - :keyword type: Type of the source uploaded. Possible values include: "Jar", "NetCoreZip", - "Source", "Container". + :keyword type: Type of the source uploaded. Known values are: "Jar", "NetCoreZip", "Source", + and "Container". :paramtype type: str or ~azure.mgmt.appplatform.v2021_06_01_preview.models.UserSourceType :keyword relative_path: Relative path of the storage which stores the source. :paramtype relative_path: str @@ -3402,7 +3198,7 @@ def __init__( :keyword custom_container: Custom container payload. :paramtype custom_container: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomContainer """ - super(UserSourceInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.relative_path = relative_path self.version = version diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/__init__.py index aa6fe5cd0cfc..a3674f282ddb 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/__init__.py @@ -18,16 +18,22 @@ from ._runtime_versions_operations import RuntimeVersionsOperations from ._skus_operations import SkusOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', + "ServicesOperations", + "ConfigServersOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_apps_operations.py index 495ec7d7c6fe..e5fb4abd1750 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_apps_operations.py @@ -6,341 +6,313 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, sync_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 sync_status is not None: - _query_parameters['syncStatus'] = _SERIALIZER.query("sync_status", sync_status, 'str') + _params["syncStatus"] = _SERIALIZER.query("sync_status", sync_status, "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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str +def build_list_request(resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_resource_upload_url_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_validate_domain_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class AppsOperations(object): - """AppsOperations 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.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.AppPlatformManagementClient`'s + :attr:`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 get( @@ -350,102 +322,125 @@ def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -453,21 +448,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -475,20 +549,24 @@ def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -501,84 +579,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -588,25 +677,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -618,83 +702,107 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -702,18 +810,97 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -721,20 +908,24 @@ def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -747,104 +938,120 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AppResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -858,10 +1065,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 @@ -871,74 +1076,138 @@ 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.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def validate_domain( @@ -946,67 +1215,86 @@ def validate_domain( resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: Union[_models.CustomDomainValidatePayload, IO], **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. :type validate_payload: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainValidatePayload + ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_bindings_operations.py index 4bca4feeddd9..49325865d231 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_bindings_operations.py @@ -6,330 +6,310 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class BindingsOperations(object): - """BindingsOperations 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.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +317,55 @@ def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -377,21 +373,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +481,27 @@ def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +514,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +536,75 @@ def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -518,28 +614,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -551,46 +641,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _update_initial( self, @@ -598,39 +696,55 @@ def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -638,18 +752,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +857,27 @@ def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +890,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +912,104 @@ def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +1023,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 @@ -816,8 +1034,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_certificates_operations.py index a2400cb2ad9a..a1967127db47 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_certificates_operations.py @@ -6,308 +6,317 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - 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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 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.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", 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.appplatform.v2021_06_01_preview.AppPlatformManagementClient`'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 get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(certificate_resource, 'CertificateResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -315,21 +324,101 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -337,21 +426,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> LROPoller["_models.CertificateResource"]: + ) -> LROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type certificate_resource: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource + ~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -364,84 +457,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -451,25 +555,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -481,98 +580,117 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +704,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 @@ -599,8 +715,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_config_servers_operations.py index be6583d00cf1..15f0e6da05b1 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_config_servers_operations.py @@ -6,311 +6,311 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_validate_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ConfigServersOperations(object): - """ConfigServersOperations 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.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -318,37 +318,115 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -361,86 +439,109 @@ def begin_update_put( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -448,37 +549,115 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -491,86 +670,109 @@ def begin_update_patch( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_settings, 'ConfigServerSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -578,37 +780,115 @@ def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerSettings + ~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -621,47 +901,54 @@ def begin_validate( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_custom_domains_operations.py index 5811473a259b..1526fd3dea9f 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_custom_domains_operations.py @@ -6,330 +6,310 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class CustomDomainsOperations(object): - """CustomDomainsOperations 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.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +317,55 @@ def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -377,21 +373,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +481,27 @@ def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +514,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +536,75 @@ def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -518,28 +614,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -551,46 +641,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _update_initial( self, @@ -598,39 +696,55 @@ def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -638,18 +752,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +857,27 @@ def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +890,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +912,105 @@ def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +1024,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 @@ -816,8 +1035,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_deployments_operations.py index 878dba4ee935..d95576958a48 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_deployments_operations.py @@ -6,534 +6,538 @@ # Code generated 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, List, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_delete_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_for_cluster_request( - subscription_id: str, resource_group_name: str, service_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_start_request_initial( - subscription_id: str, +def build_start_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_stop_request_initial( - subscription_id: str, +def build_stop_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request_initial( - subscription_id: str, +def build_restart_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_get_log_file_url_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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 DeploymentsOperations(object): - """DeploymentsOperations 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.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( self, @@ -541,39 +545,55 @@ def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -581,21 +601,107 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -604,23 +710,27 @@ def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -633,19 +743,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -653,67 +765,75 @@ def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -723,28 +843,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -756,46 +870,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _update_initial( self, @@ -803,39 +925,55 @@ def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -843,18 +981,104 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -863,23 +1087,27 @@ def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -892,19 +1120,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -912,32 +1142,37 @@ def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -947,60 +1182,72 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + ) -> Iterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1014,10 +1261,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 @@ -1027,69 +1272,76 @@ 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1103,10 +1355,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 @@ -1116,46 +1366,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1165,28 +1416,22 @@ def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1198,81 +1443,92 @@ def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1282,28 +1538,22 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1315,81 +1565,92 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -1399,28 +1660,22 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace - def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1432,98 +1687,109 @@ def begin_restart( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1532,12 +1798,11 @@ def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_monitoring_settings_operations.py index 405aed124cf7..478e1f2ac918 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_monitoring_settings_operations.py @@ -6,267 +6,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 MonitoringSettingsOperations(object): - """MonitoringSettingsOperations 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.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -274,37 +282,115 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -317,86 +403,109 @@ def begin_update_put( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -404,37 +513,115 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation 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,47 +634,54 @@ def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_operations.py index 6fcbd324a4d4..7da5775c084c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_operations.py @@ -6,111 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - accept = "application/json" +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/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.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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.appplatform.v2021_06_01_preview.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,10 +147,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 +158,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_runtime_versions_operations.py index 0a7e191e140e..6daaf3fee4d3 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_runtime_versions_operations.py @@ -6,117 +6,128 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from 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 -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_runtime_versions_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - accept = "application/json" +def build_list_runtime_versions_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/runtimeVersions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 RuntimeVersionsOperations(object): - """RuntimeVersionsOperations 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.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_services_operations.py index d4bc50e58e2c..1d6dc5d64f2b 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_services_operations.py @@ -6,564 +6,530 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_test_keys_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_regenerate_test_key_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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.AppPlatform/Spring/{serviceName}/regenerateTestKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_disable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_enable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_check_name_availability_request( - subscription_id: str, - location: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "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 - ) - - -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 ServicesOperations(object): - """ServicesOperations 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.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -571,39 +537,43 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -616,81 +586,162 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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 [202, 204]: @@ -700,22 +751,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -727,80 +772,100 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -808,36 +873,40 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -850,220 +919,379 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2021_06_01_preview.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2021_06_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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', "2021-06-01-preview") # 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", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -1073,170 +1301,245 @@ def disable_test_endpoint( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace - def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def enable_test_endpoint(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - @distributed_trace + @overload def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2021_06_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2021_06_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_06_01_preview.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] - _json = self._serialize.body(availability_parameters, 'NameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1250,10 +1553,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 @@ -1263,58 +1564,68 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1328,10 +1639,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 @@ -1341,8 +1650,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_skus_operations.py index aa37e824b969..5bcf6db5eee6 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_06_01_preview/operations/_skus_operations.py @@ -6,120 +6,140 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 SkusOperations(object): - """SkusOperations 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.appplatform.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_06_01_preview.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) + :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_06_01_preview.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # type: Literal["2021-06-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -133,10 +153,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 @@ -146,8 +164,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/__init__.py index 41ec6d71ff7f..a6bfaa2de14d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_app_platform_management_client.py index a2e6e673b5e7..36719fc8aab0 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_app_platform_management_client.py @@ -9,20 +9,33 @@ 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 .._serialization import Deserializer, Serializer from ._configuration import AppPlatformManagementClientConfiguration -from .operations import AppsOperations, BindingsOperations, CertificatesOperations, ConfigServersOperations, CustomDomainsOperations, DeploymentsOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServicesOperations, SkusOperations, StoragesOperations +from .operations import ( + AppsOperations, + BindingsOperations, + CertificatesOperations, + ConfigServersOperations, + CustomDomainsOperations, + DeploymentsOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServicesOperations, + SkusOperations, + StoragesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Cloud. :ivar services: ServicesOperations operations @@ -55,10 +68,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib azure.mgmt.appplatform.v2021_09_01_preview.operations.RuntimeVersionsOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.appplatform.v2021_09_01_preview.operations.SkusOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -76,7 +89,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -85,7 +100,9 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.storages = StoragesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -93,15 +110,12 @@ def __init__( self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -110,7 +124,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_configuration.py index 39fcf5f8106d..8bdb87f1325a 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-09-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(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-09-01-preview") # type: Literal["2021-09-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_metadata.json b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_metadata.json index e18c9b14373d..cabb9b70026b 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_metadata.json +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}, \"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\": [\"AppPlatformManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -110,4 +110,4 @@ "runtime_versions": "RuntimeVersionsOperations", "skus": "SkusOperations" } -} \ No newline at end of file +} diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_vendor.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_vendor.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_version.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_version.py index e7ffc58c0429..92453d8691d9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_version.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.1.0" +VERSION = "6.1.0" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/__init__.py index 44ce4a5043f8..398c48287ad8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._app_platform_management_client import AppPlatformManagementClient -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/_app_platform_management_client.py index 7510f58ba563..15c32a871644 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/_app_platform_management_client.py @@ -9,20 +9,33 @@ 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 AppPlatformManagementClientConfiguration -from .operations import AppsOperations, BindingsOperations, CertificatesOperations, ConfigServersOperations, CustomDomainsOperations, DeploymentsOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServicesOperations, SkusOperations, StoragesOperations +from .operations import ( + AppsOperations, + BindingsOperations, + CertificatesOperations, + ConfigServersOperations, + CustomDomainsOperations, + DeploymentsOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServicesOperations, + SkusOperations, + StoragesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Cloud. :ivar services: ServicesOperations operations @@ -55,10 +68,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib azure.mgmt.appplatform.v2021_09_01_preview.aio.operations.RuntimeVersionsOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.appplatform.v2021_09_01_preview.aio.operations.SkusOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -76,7 +89,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -85,7 +100,9 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.storages = StoragesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -93,15 +110,12 @@ def __init__( self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -110,7 +124,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/_configuration.py index 15ee10bc8930..0b92cfb1f0f3 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-09-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(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-09-01-preview") # type: Literal["2021-09-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/__init__.py index 97c71859bbd5..4ad7e9cd57be 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/__init__.py @@ -19,17 +19,23 @@ from ._runtime_versions_operations import RuntimeVersionsOperations from ._skus_operations import SkusOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'StoragesOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', + "ServicesOperations", + "ConfigServersOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "StoragesOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_apps_operations.py index 32287620c0c4..2973597042f6 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_apps_operations.py @@ -6,46 +6,67 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._apps_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_get_resource_upload_url_request, build_list_request, build_update_request_initial, build_validate_domain_request -T = TypeVar('T') +from ...operations._apps_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_get_resource_upload_url_request, + build_list_request, + build_update_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AppsOperations: - """AppsOperations 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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`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_async async def get( @@ -55,102 +76,125 @@ async def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -158,21 +202,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,20 +303,24 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -206,84 +333,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -293,25 +432,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -323,83 +457,108 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -407,18 +566,97 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -426,20 +664,24 @@ async def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -452,104 +694,121 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncIterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AppResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -563,10 +822,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 @@ -576,74 +833,138 @@ 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.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace_async async def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def validate_domain( @@ -651,67 +972,86 @@ async def validate_domain( resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: Union[_models.CustomDomainValidatePayload, IO], **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. :type validate_payload: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainValidatePayload + ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_bindings_operations.py index a025d57361ca..5962541d54af 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_bindings_operations.py @@ -6,113 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._bindings_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._bindings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BindingsOperations: - """BindingsOperations 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 BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +141,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -160,21 +197,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +305,27 @@ async def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +338,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +360,76 @@ async def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -301,28 +439,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -334,46 +466,55 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _update_initial( self, @@ -381,39 +522,55 @@ async def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -421,18 +578,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +683,27 @@ async def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +716,21 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +738,105 @@ async def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +850,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 @@ -599,8 +861,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_certificates_operations.py index 4bce9de54153..dae61aef3242 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_certificates_operations.py @@ -6,147 +6,184 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class 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.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.aio.AppPlatformManagementClient`'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_async async def get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(certificate_resource, 'CertificateResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -154,21 +191,101 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -176,21 +293,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CertificateResource"]: + ) -> AsyncLROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type certificate_resource: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource + ~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -203,84 +324,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -290,25 +423,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -320,98 +448,118 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -425,10 +573,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 @@ -438,8 +584,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_config_servers_operations.py index eb9e20893449..82f7aa3187ab 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_config_servers_operations.py @@ -6,139 +6,174 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._config_servers_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial, build_validate_request_initial -T = TypeVar('T') +from ...operations._config_servers_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConfigServersOperations: - """ConfigServersOperations 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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,37 +181,115 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,86 +302,110 @@ async def begin_update_put( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -276,37 +413,115 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -319,86 +534,110 @@ async def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_settings, 'ConfigServerSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -406,37 +645,115 @@ async def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerSettings + ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -449,47 +766,54 @@ async def begin_validate( or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = await self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_custom_domains_operations.py index b3339004bb0d..4efc869fa0fe 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_custom_domains_operations.py @@ -6,113 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._custom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CustomDomainsOperations: - """CustomDomainsOperations 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 CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +141,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -160,21 +197,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +305,27 @@ async def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +338,21 @@ async def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +360,76 @@ async def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -301,28 +439,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -334,46 +466,55 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _update_initial( self, @@ -381,39 +522,55 @@ async def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -421,18 +578,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +683,27 @@ async def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +716,21 @@ async def begin_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +738,106 @@ async def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +851,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 @@ -599,8 +862,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_deployments_operations.py index aa308ba024c6..af7edf184046 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_deployments_operations.py @@ -6,113 +6,142 @@ # Code generated 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, List, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._deployments_operations import build_create_or_update_request_initial, build_delete_request_initial, build_generate_heap_dump_request_initial, build_generate_thread_dump_request_initial, build_get_log_file_url_request, build_get_request, build_list_for_cluster_request, build_list_request, build_restart_request_initial, build_start_jfr_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._deployments_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_heap_dump_request, + build_generate_thread_dump_request, + build_get_log_file_url_request, + build_get_request, + build_list_for_cluster_request, + build_list_request, + build_restart_request, + build_start_jfr_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations 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 DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +149,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -160,21 +205,107 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,23 +314,27 @@ async def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -212,19 +347,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -232,67 +369,76 @@ async def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -302,28 +448,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -335,46 +475,55 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _update_initial( self, @@ -382,39 +531,55 @@ async def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -422,18 +587,104 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -442,23 +693,27 @@ async def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -471,19 +726,21 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -491,32 +748,38 @@ async def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -526,60 +789,72 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + ) -> AsyncIterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -593,10 +868,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 @@ -606,69 +879,76 @@ 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -682,10 +962,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 @@ -695,46 +973,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -744,28 +1023,22 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -777,81 +1050,93 @@ async def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -861,28 +1146,22 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -894,81 +1173,93 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore async def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -978,28 +1269,22 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async - async def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1011,98 +1296,110 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async async def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1111,15 +1408,14 @@ async def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1127,39 +1423,55 @@ async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-st service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_heap_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_heap_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_heap_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_heap_dump_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]: @@ -1169,33 +1481,119 @@ async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - _generate_heap_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + _generate_heap_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + @overload + async def begin_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_heap_dump( # pylint: disable=inconsistent-return-statements + async def begin_generate_heap_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Generate Heap Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1206,19 +1604,21 @@ async def begin_generate_heap_dump( # pylint: disable=inconsistent-return-state Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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._generate_heap_dump_initial( + raw_result = await self._generate_heap_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1226,29 +1626,36 @@ async def begin_generate_heap_dump( # pylint: disable=inconsistent-return-state diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_generate_heap_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + begin_generate_heap_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1256,39 +1663,55 @@ async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return- service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_thread_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_thread_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_thread_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_thread_dump_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]: @@ -1298,33 +1721,119 @@ async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return- if cls: return cls(pipeline_response, None, {}) - _generate_thread_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + _generate_thread_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + @overload + async def begin_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_thread_dump( # pylint: disable=inconsistent-return-statements + async def begin_generate_thread_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Generate Thread Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1335,19 +1844,21 @@ async def begin_generate_thread_dump( # pylint: disable=inconsistent-return-sta Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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._generate_thread_dump_initial( + raw_result = await self._generate_thread_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1355,29 +1866,36 @@ async def begin_generate_thread_dump( # pylint: disable=inconsistent-return-sta diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_generate_thread_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + begin_generate_thread_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements self, @@ -1385,39 +1903,55 @@ async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_start_jfr_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_start_jfr_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._start_jfr_initial.metadata['url'], + content=_content, + template_url=self._start_jfr_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]: @@ -1427,33 +1961,119 @@ async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_jfr_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/StartJFR"} # type: ignore + _start_jfr_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/StartJFR"} # type: ignore + + @overload + async def begin_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_start_jfr( # pylint: disable=inconsistent-return-statements + async def begin_start_jfr( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Start JFR. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1464,19 +2084,21 @@ async def begin_start_jfr( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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._start_jfr_initial( + raw_result = await self._start_jfr_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1484,26 +2106,33 @@ async def begin_start_jfr( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start_jfr.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/StartJFR"} # type: ignore + begin_start_jfr.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/StartJFR"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_monitoring_settings_operations.py index 53bd1b1ea59d..64e0038c9f1d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_monitoring_settings_operations.py @@ -6,139 +6,175 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._monitoring_settings_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial -T = TypeVar('T') +from ...operations._monitoring_settings_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MonitoringSettingsOperations: - """MonitoringSettingsOperations 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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,37 +182,115 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,86 +303,110 @@ async def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -276,37 +414,115 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -319,47 +535,55 @@ async def begin_update_patch( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_operations.py index 2cb744db3037..def1e119872a 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_operations.py @@ -6,82 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.aio.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.appplatform.v2021_09_01_preview.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,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 @@ -108,8 +134,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_runtime_versions_operations.py index e5c15de66f44..cd1b29a52864 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_runtime_versions_operations.py @@ -6,88 +6,104 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import 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._runtime_versions_operations import build_list_runtime_versions_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RuntimeVersionsOperations: - """RuntimeVersionsOperations 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 RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + async def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_services_operations.py index 2db37f6e3f77..2a85c502bb2d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_services_operations.py @@ -6,141 +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, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._services_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_disable_test_endpoint_request, build_enable_test_endpoint_request, build_get_request, build_list_by_subscription_request, build_list_request, build_list_test_keys_request, build_regenerate_test_key_request, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._services_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_disable_test_endpoint_request, + build_enable_test_endpoint_request, + build_get_request, + build_list_by_subscription_request, + build_list_request, + build_list_test_keys_request, + build_regenerate_test_key_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ServicesOperations: - """ServicesOperations 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 ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -148,39 +189,43 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -193,81 +238,163 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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 [202, 204]: @@ -277,22 +404,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -304,80 +425,101 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -385,36 +527,40 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -427,220 +573,380 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + async def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2021_09_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace_async async def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -650,98 +956,106 @@ async def disable_test_endpoint( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace_async async def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -751,22 +1065,16 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_stop(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Stop a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -778,75 +1086,89 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -856,22 +1178,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_start(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Start a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -883,147 +1199,230 @@ async def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2021_09_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(availability_parameters, 'NameAvailabilityParameters') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1037,10 +1436,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 @@ -1050,58 +1447,68 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1115,10 +1522,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 @@ -1128,8 +1533,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_skus_operations.py index 69130ae774a9..09ec9024b6a3 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_skus_operations.py @@ -6,85 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SkusOperations: - """SkusOperations 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 SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) + :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -98,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 @@ -111,8 +135,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_storages_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_storages_operations.py index e8f8d2a5f3ba..7334368ed8ae 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_storages_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/aio/operations/_storages_operations.py @@ -6,147 +6,184 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._storages_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._storages_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StoragesOperations: - """StoragesOperations 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 StoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`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 get( - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any - ) -> "_models.StorageResource": + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> _models.StorageResource: """Get the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageResource, or the result of cls(response) + :return: StorageResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> "_models.StorageResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] + ) -> _models.StorageResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(storage_resource, 'StorageResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_resource, (IO, bytes)): + _content = storage_resource + else: + _json = self._serialize.body(storage_resource, "StorageResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -154,21 +191,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: _models.StorageResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -176,20 +292,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.StorageResource"]: + ) -> AsyncLROPoller[_models.StorageResource]: """Create or update storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str - :param storage_resource: Parameters for the create or update operation. - :type storage_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource + :param storage_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -202,84 +323,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + 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, service_name=service_name, storage_name=storage_name, storage_resource=storage_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, storage_name=storage_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]: @@ -289,25 +422,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_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. @@ -319,98 +447,118 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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, service_name=service_name, storage_name=storage_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.StorageResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageResource"]: """List all the storages of one Azure Spring Cloud instance. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageResourceCollection or the result of - cls(response) + :return: An iterator like instance of either StorageResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -424,10 +572,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 @@ -437,8 +583,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/__init__.py index 169c88204eb3..562cbb589bc8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/__init__.py @@ -92,136 +92,138 @@ from ._models_py3 import TrackedResource from ._models_py3 import UserSourceInfo - -from ._app_platform_management_client_enums import ( - ActionType, - AppResourceProvisioningState, - ConfigServerState, - CreatedByType, - DeploymentResourceProvisioningState, - DeploymentResourceStatus, - ManagedIdentityType, - MonitoringSettingState, - PowerState, - ProvisioningState, - ResourceSkuRestrictionsReasonCode, - ResourceSkuRestrictionsType, - RuntimeVersion, - SkuScaleType, - StorageType, - SupportedRuntimePlatform, - SupportedRuntimeValue, - TestKeyType, - TrafficDirection, - Type, - UserSourceType, -) +from ._app_platform_management_client_enums import ActionType +from ._app_platform_management_client_enums import AppResourceProvisioningState +from ._app_platform_management_client_enums import ConfigServerState +from ._app_platform_management_client_enums import CreatedByType +from ._app_platform_management_client_enums import DeploymentResourceProvisioningState +from ._app_platform_management_client_enums import DeploymentResourceStatus +from ._app_platform_management_client_enums import ManagedIdentityType +from ._app_platform_management_client_enums import MonitoringSettingState +from ._app_platform_management_client_enums import PowerState +from ._app_platform_management_client_enums import ProvisioningState +from ._app_platform_management_client_enums import ResourceSkuRestrictionsReasonCode +from ._app_platform_management_client_enums import ResourceSkuRestrictionsType +from ._app_platform_management_client_enums import RuntimeVersion +from ._app_platform_management_client_enums import SkuScaleType +from ._app_platform_management_client_enums import StorageType +from ._app_platform_management_client_enums import SupportedRuntimePlatform +from ._app_platform_management_client_enums import SupportedRuntimeValue +from ._app_platform_management_client_enums import TestKeyType +from ._app_platform_management_client_enums import TrafficDirection +from ._app_platform_management_client_enums import Type +from ._app_platform_management_client_enums import UserSourceType +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__ = [ - 'AppResource', - 'AppResourceCollection', - 'AppResourceProperties', - 'ApplicationInsightsAgentVersions', - 'AvailableOperations', - 'AvailableRuntimeVersions', - 'AzureFileVolume', - 'BindingResource', - 'BindingResourceCollection', - 'BindingResourceProperties', - 'CertificateProperties', - 'CertificateResource', - 'CertificateResourceCollection', - 'CloudErrorBody', - 'ClusterResourceProperties', - 'ConfigServerGitProperty', - 'ConfigServerProperties', - 'ConfigServerResource', - 'ConfigServerSettings', - 'ConfigServerSettingsErrorRecord', - 'ConfigServerSettingsValidateResult', - 'ContentCertificateProperties', - 'CustomContainer', - 'CustomDomainProperties', - 'CustomDomainResource', - 'CustomDomainResourceCollection', - 'CustomDomainValidatePayload', - 'CustomDomainValidateResult', - 'CustomPersistentDiskProperties', - 'CustomPersistentDiskResource', - 'DeploymentInstance', - 'DeploymentResource', - 'DeploymentResourceCollection', - 'DeploymentResourceProperties', - 'DeploymentSettings', - 'DeploymentSettingsContainerProbeSettings', - 'DiagnosticParameters', - 'Error', - 'GitPatternRepository', - 'ImageRegistryCredential', - 'KeyVaultCertificateProperties', - 'LoadedCertificate', - 'LogFileUrlResponse', - 'LogSpecification', - 'ManagedIdentityProperties', - 'MetricDimension', - 'MetricSpecification', - 'MonitoringSettingProperties', - 'MonitoringSettingResource', - 'NameAvailability', - 'NameAvailabilityParameters', - 'NetworkProfile', - 'NetworkProfileOutboundIPs', - 'OperationDetail', - 'OperationDisplay', - 'OperationProperties', - 'PersistentDisk', - 'ProxyResource', - 'RegenerateTestKeyRequestPayload', - 'RequiredTraffic', - 'Resource', - 'ResourceRequests', - 'ResourceSku', - 'ResourceSkuCapabilities', - 'ResourceSkuCollection', - 'ResourceSkuLocationInfo', - 'ResourceSkuRestrictionInfo', - 'ResourceSkuRestrictions', - 'ResourceSkuZoneDetails', - 'ResourceUploadDefinition', - 'ServiceResource', - 'ServiceResourceList', - 'ServiceSpecification', - 'Sku', - 'SkuCapacity', - 'StorageAccount', - 'StorageProperties', - 'StorageResource', - 'StorageResourceCollection', - 'SupportedRuntimeVersion', - 'SystemData', - 'TemporaryDisk', - 'TestKeys', - 'TrackedResource', - 'UserSourceInfo', - 'ActionType', - 'AppResourceProvisioningState', - 'ConfigServerState', - 'CreatedByType', - 'DeploymentResourceProvisioningState', - 'DeploymentResourceStatus', - 'ManagedIdentityType', - 'MonitoringSettingState', - 'PowerState', - 'ProvisioningState', - 'ResourceSkuRestrictionsReasonCode', - 'ResourceSkuRestrictionsType', - 'RuntimeVersion', - 'SkuScaleType', - 'StorageType', - 'SupportedRuntimePlatform', - 'SupportedRuntimeValue', - 'TestKeyType', - 'TrafficDirection', - 'Type', - 'UserSourceType', + "AppResource", + "AppResourceCollection", + "AppResourceProperties", + "ApplicationInsightsAgentVersions", + "AvailableOperations", + "AvailableRuntimeVersions", + "AzureFileVolume", + "BindingResource", + "BindingResourceCollection", + "BindingResourceProperties", + "CertificateProperties", + "CertificateResource", + "CertificateResourceCollection", + "CloudErrorBody", + "ClusterResourceProperties", + "ConfigServerGitProperty", + "ConfigServerProperties", + "ConfigServerResource", + "ConfigServerSettings", + "ConfigServerSettingsErrorRecord", + "ConfigServerSettingsValidateResult", + "ContentCertificateProperties", + "CustomContainer", + "CustomDomainProperties", + "CustomDomainResource", + "CustomDomainResourceCollection", + "CustomDomainValidatePayload", + "CustomDomainValidateResult", + "CustomPersistentDiskProperties", + "CustomPersistentDiskResource", + "DeploymentInstance", + "DeploymentResource", + "DeploymentResourceCollection", + "DeploymentResourceProperties", + "DeploymentSettings", + "DeploymentSettingsContainerProbeSettings", + "DiagnosticParameters", + "Error", + "GitPatternRepository", + "ImageRegistryCredential", + "KeyVaultCertificateProperties", + "LoadedCertificate", + "LogFileUrlResponse", + "LogSpecification", + "ManagedIdentityProperties", + "MetricDimension", + "MetricSpecification", + "MonitoringSettingProperties", + "MonitoringSettingResource", + "NameAvailability", + "NameAvailabilityParameters", + "NetworkProfile", + "NetworkProfileOutboundIPs", + "OperationDetail", + "OperationDisplay", + "OperationProperties", + "PersistentDisk", + "ProxyResource", + "RegenerateTestKeyRequestPayload", + "RequiredTraffic", + "Resource", + "ResourceRequests", + "ResourceSku", + "ResourceSkuCapabilities", + "ResourceSkuCollection", + "ResourceSkuLocationInfo", + "ResourceSkuRestrictionInfo", + "ResourceSkuRestrictions", + "ResourceSkuZoneDetails", + "ResourceUploadDefinition", + "ServiceResource", + "ServiceResourceList", + "ServiceSpecification", + "Sku", + "SkuCapacity", + "StorageAccount", + "StorageProperties", + "StorageResource", + "StorageResourceCollection", + "SupportedRuntimeVersion", + "SystemData", + "TemporaryDisk", + "TestKeys", + "TrackedResource", + "UserSourceInfo", + "ActionType", + "AppResourceProvisioningState", + "ConfigServerState", + "CreatedByType", + "DeploymentResourceProvisioningState", + "DeploymentResourceStatus", + "ManagedIdentityType", + "MonitoringSettingState", + "PowerState", + "ProvisioningState", + "ResourceSkuRestrictionsReasonCode", + "ResourceSkuRestrictionsType", + "RuntimeVersion", + "SkuScaleType", + "StorageType", + "SupportedRuntimePlatform", + "SupportedRuntimeValue", + "TestKeyType", + "TrafficDirection", + "Type", + "UserSourceType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/_app_platform_management_client_enums.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/_app_platform_management_client_enums.py index 8a48df4eabc6..e3501c5d160d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/_app_platform_management_client_enums.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/_app_platform_management_client_enums.py @@ -7,28 +7,26 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - """ +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" INTERNAL = "Internal" -class AppResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the App - """ + +class AppResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the App.""" SUCCEEDED = "Succeeded" FAILED = "Failed" CREATING = "Creating" UPDATING = "Updating" -class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the config server. - """ + +class ConfigServerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the config server.""" NOT_AVAILABLE = "NotAvailable" DELETED = "Deleted" @@ -36,27 +34,27 @@ class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -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 DeploymentResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Deployment - """ + +class DeploymentResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Deployment.""" CREATING = "Creating" UPDATING = "Updating" SUCCEEDED = "Succeeded" FAILED = "Failed" -class DeploymentResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of the Deployment - """ + +class DeploymentResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the Deployment.""" UNKNOWN = "Unknown" STOPPED = "Stopped" @@ -66,34 +64,34 @@ class DeploymentResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum UPGRADING = "Upgrading" COMPILING = "Compiling" -class ManagedIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the managed identity - """ + +class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the managed identity.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class MonitoringSettingState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Monitoring Setting. - """ + +class MonitoringSettingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Monitoring Setting.""" NOT_AVAILABLE = "NotAvailable" FAILED = "Failed" SUCCEEDED = "Succeeded" UPDATING = "Updating" -class PowerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Power state of the Service - """ + +class PowerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Power state of the Service.""" RUNNING = "Running" STOPPED = "Stopped" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Service - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Service.""" CREATING = "Creating" UPDATING = "Updating" @@ -107,81 +105,82 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MOVED = "Moved" MOVE_FAILED = "MoveFailed" -class ResourceSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription' + 'NotAvailableForSubscription'. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ResourceSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets the type of restrictions. Possible values include: 'Location', 'Zone' - """ + +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the type of restrictions. Possible values include: 'Location', 'Zone'.""" LOCATION = "Location" ZONE = "Zone" -class RuntimeVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Runtime version - """ + +class RuntimeVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Runtime version.""" JAVA8 = "Java_8" JAVA11 = "Java_11" NET_CORE31 = "NetCore_31" -class SkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets or sets the type of the scale. - """ + +class SkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type of the scale.""" NONE = "None" MANUAL = "Manual" AUTOMATIC = "Automatic" -class StorageType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the storage. - """ + +class StorageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the storage.""" STORAGE_ACCOUNT = "StorageAccount" -class SupportedRuntimePlatform(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The platform of this runtime version (possible values: "Java" or ".NET"). - """ + +class SupportedRuntimePlatform(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The platform of this runtime version (possible values: "Java" or ".NET").""" JAVA = "Java" _NET_CORE = ".NET Core" -class SupportedRuntimeValue(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The raw value which could be passed to deployment CRUD operations. - """ + +class SupportedRuntimeValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The raw value which could be passed to deployment CRUD operations.""" JAVA8 = "Java_8" JAVA11 = "Java_11" NET_CORE31 = "NetCore_31" -class TestKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the test key - """ + +class TestKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the test key.""" PRIMARY = "Primary" SECONDARY = "Secondary" -class TrafficDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The direction of required traffic - """ + +class TrafficDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The direction of required traffic.""" INBOUND = "Inbound" OUTBOUND = "Outbound" -class Type(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the underlying resource to mount as a persistent disk. - """ + +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the underlying resource to mount as a persistent disk.""" AZURE_FILE_VOLUME = "AzureFileVolume" -class UserSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the source uploaded - """ + +class UserSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the source uploaded.""" JAR = "Jar" NET_CORE_ZIP = "NetCoreZip" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/_models_py3.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/_models_py3.py index a3645379c047..0937814cf0cd 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/_models_py3.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,14 +8,23 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._app_platform_management_client_enums import * +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ApplicationInsightsAgentVersions(msrest.serialization.Model): + +class ApplicationInsightsAgentVersions(_serialization.Model): """Application Insights agent versions properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -24,24 +34,20 @@ class ApplicationInsightsAgentVersions(msrest.serialization.Model): """ _validation = { - 'java': {'readonly': True}, + "java": {"readonly": True}, } _attribute_map = { - 'java': {'key': 'java', 'type': 'str'}, + "java": {"key": "java", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApplicationInsightsAgentVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.java = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The core properties of ARM resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -55,24 +61,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -92,24 +94,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class AppResource(ProxyResource): @@ -132,25 +130,25 @@ class AppResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'AppResourceProperties'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentityProperties'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "AppResourceProperties"}, + "identity": {"key": "identity", "type": "ManagedIdentityProperties"}, + "location": {"key": "location", "type": "str"}, } def __init__( self, *, - properties: Optional["AppResourceProperties"] = None, - identity: Optional["ManagedIdentityProperties"] = None, + properties: Optional["_models.AppResourceProperties"] = None, + identity: Optional["_models.ManagedIdentityProperties"] = None, location: Optional[str] = None, **kwargs ): @@ -164,13 +162,13 @@ def __init__( resource. :paramtype location: str """ - super(AppResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.identity = identity self.location = location -class AppResourceCollection(msrest.serialization.Model): +class AppResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of App resources. @@ -181,16 +179,12 @@ class AppResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AppResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AppResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["AppResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.AppResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of App resources. @@ -199,12 +193,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(AppResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class AppResourceProperties(msrest.serialization.Model): +class AppResourceProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """App resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -213,8 +207,8 @@ class AppResourceProperties(msrest.serialization.Model): :vartype public: bool :ivar url: URL of the App. :vartype url: str - :ivar provisioning_state: Provisioning state of the App. Possible values include: "Succeeded", - "Failed", "Creating", "Updating". + :ivar provisioning_state: Provisioning state of the App. Known values are: "Succeeded", + "Failed", "Creating", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResourceProvisioningState :ivar active_deployment_name: Name of the active deployment of the App. @@ -240,24 +234,24 @@ class AppResourceProperties(msrest.serialization.Model): """ _validation = { - 'url': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'created_time': {'readonly': True}, + "url": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "created_time": {"readonly": True}, } _attribute_map = { - 'public': {'key': 'public', 'type': 'bool'}, - 'url': {'key': 'url', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'active_deployment_name': {'key': 'activeDeploymentName', 'type': 'str'}, - 'fqdn': {'key': 'fqdn', 'type': 'str'}, - 'https_only': {'key': 'httpsOnly', 'type': 'bool'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'temporary_disk': {'key': 'temporaryDisk', 'type': 'TemporaryDisk'}, - 'persistent_disk': {'key': 'persistentDisk', 'type': 'PersistentDisk'}, - 'custom_persistent_disks': {'key': 'customPersistentDisks', 'type': '[CustomPersistentDiskResource]'}, - 'enable_end_to_end_tls': {'key': 'enableEndToEndTLS', 'type': 'bool'}, - 'loaded_certificates': {'key': 'loadedCertificates', 'type': '[LoadedCertificate]'}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "active_deployment_name": {"key": "activeDeploymentName", "type": "str"}, + "fqdn": {"key": "fqdn", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "temporary_disk": {"key": "temporaryDisk", "type": "TemporaryDisk"}, + "persistent_disk": {"key": "persistentDisk", "type": "PersistentDisk"}, + "custom_persistent_disks": {"key": "customPersistentDisks", "type": "[CustomPersistentDiskResource]"}, + "enable_end_to_end_tls": {"key": "enableEndToEndTLS", "type": "bool"}, + "loaded_certificates": {"key": "loadedCertificates", "type": "[LoadedCertificate]"}, } def __init__( @@ -266,12 +260,12 @@ def __init__( public: Optional[bool] = None, active_deployment_name: Optional[str] = None, fqdn: Optional[str] = None, - https_only: Optional[bool] = False, - temporary_disk: Optional["TemporaryDisk"] = None, - persistent_disk: Optional["PersistentDisk"] = None, - custom_persistent_disks: Optional[List["CustomPersistentDiskResource"]] = None, - enable_end_to_end_tls: Optional[bool] = False, - loaded_certificates: Optional[List["LoadedCertificate"]] = None, + https_only: bool = False, + temporary_disk: Optional["_models.TemporaryDisk"] = None, + persistent_disk: Optional["_models.PersistentDisk"] = None, + custom_persistent_disks: Optional[List["_models.CustomPersistentDiskResource"]] = None, + enable_end_to_end_tls: bool = False, + loaded_certificates: Optional[List["_models.LoadedCertificate"]] = None, **kwargs ): """ @@ -296,7 +290,7 @@ def __init__( :paramtype loaded_certificates: list[~azure.mgmt.appplatform.v2021_09_01_preview.models.LoadedCertificate] """ - super(AppResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.public = public self.url = None self.provisioning_state = None @@ -311,7 +305,7 @@ def __init__( self.loaded_certificates = loaded_certificates -class AvailableOperations(msrest.serialization.Model): +class AvailableOperations(_serialization.Model): """Available operations of the service. :ivar value: Collection of available operation details. @@ -322,16 +316,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. @@ -340,12 +330,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 AvailableRuntimeVersions(msrest.serialization.Model): +class AvailableRuntimeVersions(_serialization.Model): """AvailableRuntimeVersions. Variables are only populated by the server, and will be ignored when sending a request. @@ -356,35 +346,31 @@ class AvailableRuntimeVersions(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedRuntimeVersion]'}, + "value": {"key": "value", "type": "[SupportedRuntimeVersion]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AvailableRuntimeVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class CustomPersistentDiskProperties(msrest.serialization.Model): +class CustomPersistentDiskProperties(_serialization.Model): """Custom persistent disk resource payload. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureFileVolume. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureFileVolume All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the underlying resource to mount as a persistent - disk.Constant filled by server. Possible values include: "AzureFileVolume". + :ivar type: The type of the underlying resource to mount as a persistent disk. Required. + "AzureFileVolume" :vartype type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.Type - :ivar mount_path: Required. The mount path of the persistent disk. + :ivar mount_path: The mount path of the persistent disk. Required. :vartype mount_path: str :ivar read_only: Indicates whether the persistent disk is a readOnly one. :vartype read_only: bool @@ -393,38 +379,31 @@ class CustomPersistentDiskProperties(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, - 'mount_path': {'required': True}, + "type": {"required": True}, + "mount_path": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, - 'read_only': {'key': 'readOnly', 'type': 'bool'}, - 'mount_options': {'key': 'mountOptions', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "mount_path": {"key": "mountPath", "type": "str"}, + "read_only": {"key": "readOnly", "type": "bool"}, + "mount_options": {"key": "mountOptions", "type": "[str]"}, } - _subtype_map = { - 'type': {'AzureFileVolume': 'AzureFileVolume'} - } + _subtype_map = {"type": {"AzureFileVolume": "AzureFileVolume"}} def __init__( - self, - *, - mount_path: str, - read_only: Optional[bool] = None, - mount_options: Optional[List[str]] = None, - **kwargs + self, *, mount_path: str, read_only: Optional[bool] = None, mount_options: Optional[List[str]] = None, **kwargs ): """ - :keyword mount_path: Required. The mount path of the persistent disk. + :keyword mount_path: The mount path of the persistent disk. Required. :paramtype mount_path: str :keyword read_only: Indicates whether the persistent disk is a readOnly one. :paramtype read_only: bool :keyword mount_options: These are the mount options for a persistent disk. :paramtype mount_options: list[str] """ - super(CustomPersistentDiskProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None # type: Optional[str] self.mount_path = mount_path self.read_only = read_only @@ -436,31 +415,31 @@ class AzureFileVolume(CustomPersistentDiskProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the underlying resource to mount as a persistent - disk.Constant filled by server. Possible values include: "AzureFileVolume". + :ivar type: The type of the underlying resource to mount as a persistent disk. Required. + "AzureFileVolume" :vartype type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.Type - :ivar mount_path: Required. The mount path of the persistent disk. + :ivar mount_path: The mount path of the persistent disk. Required. :vartype mount_path: str :ivar read_only: Indicates whether the persistent disk is a readOnly one. :vartype read_only: bool :ivar mount_options: These are the mount options for a persistent disk. :vartype mount_options: list[str] - :ivar share_name: Required. The share name of the Azure File share. + :ivar share_name: The share name of the Azure File share. Required. :vartype share_name: str """ _validation = { - 'type': {'required': True}, - 'mount_path': {'required': True}, - 'share_name': {'required': True}, + "type": {"required": True}, + "mount_path": {"required": True}, + "share_name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, - 'read_only': {'key': 'readOnly', 'type': 'bool'}, - 'mount_options': {'key': 'mountOptions', 'type': '[str]'}, - 'share_name': {'key': 'shareName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "mount_path": {"key": "mountPath", "type": "str"}, + "read_only": {"key": "readOnly", "type": "bool"}, + "mount_options": {"key": "mountOptions", "type": "[str]"}, + "share_name": {"key": "shareName", "type": "str"}, } def __init__( @@ -473,17 +452,17 @@ def __init__( **kwargs ): """ - :keyword mount_path: Required. The mount path of the persistent disk. + :keyword mount_path: The mount path of the persistent disk. Required. :paramtype mount_path: str :keyword read_only: Indicates whether the persistent disk is a readOnly one. :paramtype read_only: bool :keyword mount_options: These are the mount options for a persistent disk. :paramtype mount_options: list[str] - :keyword share_name: Required. The share name of the Azure File share. + :keyword share_name: The share name of the Azure File share. Required. :paramtype share_name: str """ - super(AzureFileVolume, self).__init__(mount_path=mount_path, read_only=read_only, mount_options=mount_options, **kwargs) - self.type = 'AzureFileVolume' # type: str + super().__init__(mount_path=mount_path, read_only=read_only, mount_options=mount_options, **kwargs) + self.type = "AzureFileVolume" # type: str self.share_name = share_name @@ -504,34 +483,29 @@ class BindingResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'BindingResourceProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "BindingResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["BindingResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BindingResourceProperties"] = None, **kwargs): """ :keyword properties: Properties of the Binding resource. :paramtype properties: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResourceProperties """ - super(BindingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BindingResourceCollection(msrest.serialization.Model): +class BindingResourceCollection(_serialization.Model): """Object that includes an array of Binding resources and a possible link for next set. :ivar value: Collection of Binding resources. @@ -542,16 +516,12 @@ class BindingResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BindingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BindingResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BindingResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Binding resources. @@ -560,12 +530,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BindingResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BindingResourceProperties(msrest.serialization.Model): +class BindingResourceProperties(_serialization.Model): """Binding resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -579,7 +549,7 @@ class BindingResourceProperties(msrest.serialization.Model): :ivar key: The key of the bound resource. :vartype key: str :ivar binding_parameters: Binding parameters of the Binding resource. - :vartype binding_parameters: dict[str, any] + :vartype binding_parameters: dict[str, JSON] :ivar generated_properties: The generated Spring Boot property file for this binding. The secret will be deducted. :vartype generated_properties: str @@ -590,22 +560,22 @@ class BindingResourceProperties(msrest.serialization.Model): """ _validation = { - 'resource_name': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'generated_properties': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, + "resource_name": {"readonly": True}, + "resource_type": {"readonly": True}, + "generated_properties": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, } _attribute_map = { - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'binding_parameters': {'key': 'bindingParameters', 'type': '{object}'}, - 'generated_properties': {'key': 'generatedProperties', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'str'}, - 'updated_at': {'key': 'updatedAt', 'type': 'str'}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "binding_parameters": {"key": "bindingParameters", "type": "{object}"}, + "generated_properties": {"key": "generatedProperties", "type": "str"}, + "created_at": {"key": "createdAt", "type": "str"}, + "updated_at": {"key": "updatedAt", "type": "str"}, } def __init__( @@ -613,7 +583,7 @@ def __init__( *, resource_id: Optional[str] = None, key: Optional[str] = None, - binding_parameters: Optional[Dict[str, Any]] = None, + binding_parameters: Optional[Dict[str, JSON]] = None, **kwargs ): """ @@ -622,9 +592,9 @@ def __init__( :keyword key: The key of the bound resource. :paramtype key: str :keyword binding_parameters: Binding parameters of the Binding resource. - :paramtype binding_parameters: dict[str, any] + :paramtype binding_parameters: dict[str, JSON] """ - super(BindingResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_name = None self.resource_type = None self.resource_id = resource_id @@ -635,17 +605,17 @@ def __init__( self.updated_at = None -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """Certificate resource payload. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ContentCertificateProperties, KeyVaultCertificateProperties. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContentCertificateProperties, KeyVaultCertificateProperties Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -664,38 +634,37 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, } _subtype_map = { - 'type': {'ContentCertificate': 'ContentCertificateProperties', 'KeyVaultCertificate': 'KeyVaultCertificateProperties'} + "type": { + "ContentCertificate": "ContentCertificateProperties", + "KeyVaultCertificate": "KeyVaultCertificateProperties", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificateProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None # type: Optional[str] self.thumbprint = None self.issuer = None @@ -722,33 +691,28 @@ class CertificateResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "CertificateProperties"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: Properties of the certificate resource payload. :paramtype properties: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateProperties """ - super(CertificateResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CertificateResourceCollection(msrest.serialization.Model): +class CertificateResourceCollection(_serialization.Model): """Collection compose of certificate resources list and a possible link for next page. :ivar value: The certificate resources list. @@ -758,16 +722,12 @@ class CertificateResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CertificateResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CertificateResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CertificateResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The certificate resources list. @@ -775,12 +735,12 @@ def __init__( :keyword next_link: The link to next page of certificate list. :paramtype next_link: str """ - super(CertificateResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -797,10 +757,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -809,7 +769,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -825,21 +785,21 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.appplatform.v2021_09_01_preview.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class ClusterResourceProperties(msrest.serialization.Model): +class ClusterResourceProperties(_serialization.Model): """Service properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Provisioning state of the Service. Possible values include: - "Creating", "Updating", "Starting", "Stopping", "Deleting", "Deleted", "Succeeded", "Failed", - "Moving", "Moved", "MoveFailed". + :ivar provisioning_state: Provisioning state of the Service. Known values are: "Creating", + "Updating", "Starting", "Stopping", "Deleting", "Deleted", "Succeeded", "Failed", "Moving", + "Moved", and "MoveFailed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.ProvisioningState :ivar network_profile: Network profile of the Service. @@ -848,36 +808,31 @@ class ClusterResourceProperties(msrest.serialization.Model): :vartype version: int :ivar service_id: ServiceInstanceEntity GUID which uniquely identifies a created resource. :vartype service_id: str - :ivar power_state: Power state of the Service. Possible values include: "Running", "Stopped". + :ivar power_state: Power state of the Service. Known values are: "Running" and "Stopped". :vartype power_state: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.PowerState """ _validation = { - 'provisioning_state': {'readonly': True}, - 'version': {'readonly': True}, - 'service_id': {'readonly': True}, - 'power_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "service_id": {"readonly": True}, + "power_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'network_profile': {'key': 'networkProfile', 'type': 'NetworkProfile'}, - 'version': {'key': 'version', 'type': 'int'}, - 'service_id': {'key': 'serviceId', 'type': 'str'}, - 'power_state': {'key': 'powerState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "network_profile": {"key": "networkProfile", "type": "NetworkProfile"}, + "version": {"key": "version", "type": "int"}, + "service_id": {"key": "serviceId", "type": "str"}, + "power_state": {"key": "powerState", "type": "str"}, } - def __init__( - self, - *, - network_profile: Optional["NetworkProfile"] = None, - **kwargs - ): + def __init__(self, *, network_profile: Optional["_models.NetworkProfile"] = None, **kwargs): """ :keyword network_profile: Network profile of the Service. :paramtype network_profile: ~azure.mgmt.appplatform.v2021_09_01_preview.models.NetworkProfile """ - super(ClusterResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.network_profile = network_profile self.version = None @@ -885,7 +840,7 @@ def __init__( self.power_state = None -class ConfigServerGitProperty(msrest.serialization.Model): +class ConfigServerGitProperty(_serialization.Model): """Property of git. All required parameters must be populated in order to send to Azure. @@ -893,7 +848,7 @@ class ConfigServerGitProperty(msrest.serialization.Model): :ivar repositories: Repositories of git. :vartype repositories: list[~azure.mgmt.appplatform.v2021_09_01_preview.models.GitPatternRepository] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -914,27 +869,27 @@ class ConfigServerGitProperty(msrest.serialization.Model): """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'repositories': {'key': 'repositories', 'type': '[GitPatternRepository]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "repositories": {"key": "repositories", "type": "[GitPatternRepository]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( self, *, uri: str, - repositories: Optional[List["GitPatternRepository"]] = None, + repositories: Optional[List["_models.GitPatternRepository"]] = None, label: Optional[str] = None, search_paths: Optional[List[str]] = None, username: Optional[str] = None, @@ -949,7 +904,7 @@ def __init__( :keyword repositories: Repositories of git. :paramtype repositories: list[~azure.mgmt.appplatform.v2021_09_01_preview.models.GitPatternRepository] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -968,7 +923,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(ConfigServerGitProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.repositories = repositories self.uri = uri self.label = label @@ -981,13 +936,13 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ConfigServerProperties(msrest.serialization.Model): +class ConfigServerProperties(_serialization.Model): """Config server git properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the config server. Possible values include: "NotAvailable", - "Deleted", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the config server. Known values are: "NotAvailable", + "Deleted", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerState :ivar error: Error when apply config server settings. @@ -997,20 +952,20 @@ class ConfigServerProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'config_server': {'key': 'configServer', 'type': 'ConfigServerSettings'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "config_server": {"key": "configServer", "type": "ConfigServerSettings"}, } def __init__( self, *, - error: Optional["Error"] = None, - config_server: Optional["ConfigServerSettings"] = None, + error: Optional["_models.Error"] = None, + config_server: Optional["_models.ConfigServerSettings"] = None, **kwargs ): """ @@ -1020,7 +975,7 @@ def __init__( :paramtype config_server: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerSettings """ - super(ConfigServerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.config_server = config_server @@ -1042,34 +997,29 @@ class ConfigServerResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ConfigServerProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ConfigServerProperties"}, } - def __init__( - self, - *, - properties: Optional["ConfigServerProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ConfigServerProperties"] = None, **kwargs): """ :keyword properties: Properties of the Config Server resource. :paramtype properties: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerProperties """ - super(ConfigServerResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ConfigServerSettings(msrest.serialization.Model): +class ConfigServerSettings(_serialization.Model): """The settings of config server. :ivar git_property: Property of git environment. @@ -1078,25 +1028,20 @@ class ConfigServerSettings(msrest.serialization.Model): """ _attribute_map = { - 'git_property': {'key': 'gitProperty', 'type': 'ConfigServerGitProperty'}, + "git_property": {"key": "gitProperty", "type": "ConfigServerGitProperty"}, } - def __init__( - self, - *, - git_property: Optional["ConfigServerGitProperty"] = None, - **kwargs - ): + def __init__(self, *, git_property: Optional["_models.ConfigServerGitProperty"] = None, **kwargs): """ :keyword git_property: Property of git environment. :paramtype git_property: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerGitProperty """ - super(ConfigServerSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property = git_property -class ConfigServerSettingsErrorRecord(msrest.serialization.Model): +class ConfigServerSettingsErrorRecord(_serialization.Model): """Error record of the config server settings. :ivar name: The name of the config server settings error record. @@ -1108,18 +1053,13 @@ class ConfigServerSettingsErrorRecord(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'messages': {'key': 'messages', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, } def __init__( - self, - *, - name: Optional[str] = None, - uri: Optional[str] = None, - messages: Optional[List[str]] = None, - **kwargs + self, *, name: Optional[str] = None, uri: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs ): """ :keyword name: The name of the config server settings error record. @@ -1129,13 +1069,13 @@ def __init__( :keyword messages: The detail error messages of the record. :paramtype messages: list[str] """ - super(ConfigServerSettingsErrorRecord, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.uri = uri self.messages = messages -class ConfigServerSettingsValidateResult(msrest.serialization.Model): +class ConfigServerSettingsValidateResult(_serialization.Model): """Validation result for config server settings. :ivar is_valid: Indicate if the config server settings are valid. @@ -1146,15 +1086,15 @@ class ConfigServerSettingsValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'details': {'key': 'details', 'type': '[ConfigServerSettingsErrorRecord]'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "details": {"key": "details", "type": "[ConfigServerSettingsErrorRecord]"}, } def __init__( self, *, is_valid: Optional[bool] = None, - details: Optional[List["ConfigServerSettingsErrorRecord"]] = None, + details: Optional[List["_models.ConfigServerSettingsErrorRecord"]] = None, **kwargs ): """ @@ -1164,7 +1104,7 @@ def __init__( :paramtype details: list[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerSettingsErrorRecord] """ - super(ConfigServerSettingsValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.details = details @@ -1176,7 +1116,7 @@ class ContentCertificateProperties(CertificateProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -1197,44 +1137,39 @@ class ContentCertificateProperties(CertificateProperties): """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, - 'content': {'key': 'content', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "content": {"key": "content", "type": "str"}, } - def __init__( - self, - *, - content: Optional[str] = None, - **kwargs - ): + def __init__(self, *, content: Optional[str] = None, **kwargs): """ :keyword content: The content of uploaded certificate. :paramtype content: str """ - super(ContentCertificateProperties, self).__init__(**kwargs) - self.type = 'ContentCertificate' # type: str + super().__init__(**kwargs) + self.type = "ContentCertificate" # type: str self.content = content -class CustomContainer(msrest.serialization.Model): +class CustomContainer(_serialization.Model): """Custom container payload. :ivar server: The name of the registry that contains the container image. @@ -1254,11 +1189,11 @@ class CustomContainer(msrest.serialization.Model): """ _attribute_map = { - 'server': {'key': 'server', 'type': 'str'}, - 'container_image': {'key': 'containerImage', 'type': 'str'}, - 'command': {'key': 'command', 'type': '[str]'}, - 'args': {'key': 'args', 'type': '[str]'}, - 'image_registry_credential': {'key': 'imageRegistryCredential', 'type': 'ImageRegistryCredential'}, + "server": {"key": "server", "type": "str"}, + "container_image": {"key": "containerImage", "type": "str"}, + "command": {"key": "command", "type": "[str]"}, + "args": {"key": "args", "type": "[str]"}, + "image_registry_credential": {"key": "imageRegistryCredential", "type": "ImageRegistryCredential"}, } def __init__( @@ -1268,7 +1203,7 @@ def __init__( container_image: Optional[str] = None, command: Optional[List[str]] = None, args: Optional[List[str]] = None, - image_registry_credential: Optional["ImageRegistryCredential"] = None, + image_registry_credential: Optional["_models.ImageRegistryCredential"] = None, **kwargs ): """ @@ -1287,7 +1222,7 @@ def __init__( :paramtype image_registry_credential: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ImageRegistryCredential """ - super(CustomContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.server = server self.container_image = container_image self.command = command @@ -1295,7 +1230,7 @@ def __init__( self.image_registry_credential = image_registry_credential -class CustomDomainProperties(msrest.serialization.Model): +class CustomDomainProperties(_serialization.Model): """Custom domain of app resource payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1309,29 +1244,23 @@ class CustomDomainProperties(msrest.serialization.Model): """ _validation = { - 'app_name': {'readonly': True}, + "app_name": {"readonly": True}, } _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'app_name': {'key': 'appName', 'type': 'str'}, - 'cert_name': {'key': 'certName', 'type': 'str'}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "app_name": {"key": "appName", "type": "str"}, + "cert_name": {"key": "certName", "type": "str"}, } - def __init__( - self, - *, - thumbprint: Optional[str] = None, - cert_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, thumbprint: Optional[str] = None, cert_name: Optional[str] = None, **kwargs): """ :keyword thumbprint: The thumbprint of bound certificate. :paramtype thumbprint: str :keyword cert_name: The bound certificate name of domain. :paramtype cert_name: str """ - super(CustomDomainProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = thumbprint self.app_name = None self.cert_name = cert_name @@ -1353,34 +1282,29 @@ class CustomDomainResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'CustomDomainProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "CustomDomainProperties"}, } - def __init__( - self, - *, - properties: Optional["CustomDomainProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CustomDomainProperties"] = None, **kwargs): """ :keyword properties: Properties of the custom domain resource. :paramtype properties: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainProperties """ - super(CustomDomainResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CustomDomainResourceCollection(msrest.serialization.Model): +class CustomDomainResourceCollection(_serialization.Model): """Collection compose of a custom domain resources list and a possible link for next page. :ivar value: The custom domain resources list. @@ -1390,16 +1314,12 @@ class CustomDomainResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CustomDomainResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CustomDomainResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The custom domain resources list. @@ -1407,43 +1327,38 @@ def __init__( :keyword next_link: The link to next page of custom domain list. :paramtype next_link: str """ - super(CustomDomainResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CustomDomainValidatePayload(msrest.serialization.Model): +class CustomDomainValidatePayload(_serialization.Model): """Custom domain validate payload. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name to be validated. + :ivar name: Name to be validated. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Name to be validated. + :keyword name: Name to be validated. Required. :paramtype name: str """ - super(CustomDomainValidatePayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CustomDomainValidateResult(msrest.serialization.Model): +class CustomDomainValidateResult(_serialization.Model): """Validation result for custom domain. :ivar is_valid: Indicates if domain name is valid. @@ -1453,29 +1368,23 @@ class CustomDomainValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'message': {'key': 'message', 'type': 'str'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - is_valid: Optional[bool] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, is_valid: Optional[bool] = None, message: Optional[str] = None, **kwargs): """ :keyword is_valid: Indicates if domain name is valid. :paramtype is_valid: bool :keyword message: Message of why domain name is invalid. :paramtype message: str """ - super(CustomDomainValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.message = message -class CustomPersistentDiskResource(msrest.serialization.Model): +class CustomPersistentDiskResource(_serialization.Model): """Custom persistent disk resource payload. All required parameters must be populated in order to send to Azure. @@ -1484,24 +1393,27 @@ class CustomPersistentDiskResource(msrest.serialization.Model): payload. :vartype custom_persistent_disk_properties: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomPersistentDiskProperties - :ivar storage_id: Required. The resource id of Azure Spring Cloud Storage resource. + :ivar storage_id: The resource id of Azure Spring Cloud Storage resource. Required. :vartype storage_id: str """ _validation = { - 'storage_id': {'required': True}, + "storage_id": {"required": True}, } _attribute_map = { - 'custom_persistent_disk_properties': {'key': 'customPersistentDiskProperties', 'type': 'CustomPersistentDiskProperties'}, - 'storage_id': {'key': 'storageId', 'type': 'str'}, + "custom_persistent_disk_properties": { + "key": "customPersistentDiskProperties", + "type": "CustomPersistentDiskProperties", + }, + "storage_id": {"key": "storageId", "type": "str"}, } def __init__( self, *, storage_id: str, - custom_persistent_disk_properties: Optional["CustomPersistentDiskProperties"] = None, + custom_persistent_disk_properties: Optional["_models.CustomPersistentDiskProperties"] = None, **kwargs ): """ @@ -1509,15 +1421,15 @@ def __init__( payload. :paramtype custom_persistent_disk_properties: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomPersistentDiskProperties - :keyword storage_id: Required. The resource id of Azure Spring Cloud Storage resource. + :keyword storage_id: The resource id of Azure Spring Cloud Storage resource. Required. :paramtype storage_id: str """ - super(CustomPersistentDiskResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.custom_persistent_disk_properties = custom_persistent_disk_properties self.storage_id = storage_id -class DeploymentInstance(msrest.serialization.Model): +class DeploymentInstance(_serialization.Model): """Deployment instance payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1535,28 +1447,24 @@ class DeploymentInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, - 'reason': {'readonly': True}, - 'discovery_status': {'readonly': True}, - 'start_time': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, + "reason": {"readonly": True}, + "discovery_status": {"readonly": True}, + "start_time": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'discovery_status': {'key': 'discoveryStatus', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "discovery_status": {"key": "discoveryStatus", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None self.reason = None @@ -1583,24 +1491,24 @@ class DeploymentResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( self, *, - properties: Optional["DeploymentResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.DeploymentResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -1610,12 +1518,12 @@ def __init__( :keyword sku: Sku of the Deployment resource. :paramtype sku: ~azure.mgmt.appplatform.v2021_09_01_preview.models.Sku """ - super(DeploymentResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.sku = sku -class DeploymentResourceCollection(msrest.serialization.Model): +class DeploymentResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of Deployment resources. @@ -1626,16 +1534,12 @@ class DeploymentResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["DeploymentResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.DeploymentResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Deployment resources. @@ -1644,12 +1548,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(DeploymentResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class DeploymentResourceProperties(msrest.serialization.Model): +class DeploymentResourceProperties(_serialization.Model): """Deployment resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1661,12 +1565,12 @@ class DeploymentResourceProperties(msrest.serialization.Model): :ivar deployment_settings: Deployment settings of the Deployment. :vartype deployment_settings: ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentSettings - :ivar provisioning_state: Provisioning state of the Deployment. Possible values include: - "Creating", "Updating", "Succeeded", "Failed". + :ivar provisioning_state: Provisioning state of the Deployment. Known values are: "Creating", + "Updating", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResourceProvisioningState - :ivar status: Status of the Deployment. Possible values include: "Unknown", "Stopped", - "Running", "Failed", "Allocating", "Upgrading", "Compiling". + :ivar status: Status of the Deployment. Known values are: "Unknown", "Stopped", "Running", + "Failed", "Allocating", "Upgrading", and "Compiling". :vartype status: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResourceStatus :ivar active: Indicates whether the Deployment is active. @@ -1678,30 +1582,30 @@ class DeploymentResourceProperties(msrest.serialization.Model): """ _validation = { - 'app_name': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'active': {'readonly': True}, - 'created_time': {'readonly': True}, - 'instances': {'readonly': True}, + "app_name": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "active": {"readonly": True}, + "created_time": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'UserSourceInfo'}, - 'app_name': {'key': 'appName', 'type': 'str'}, - 'deployment_settings': {'key': 'deploymentSettings', 'type': 'DeploymentSettings'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'active': {'key': 'active', 'type': 'bool'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'instances': {'key': 'instances', 'type': '[DeploymentInstance]'}, + "source": {"key": "source", "type": "UserSourceInfo"}, + "app_name": {"key": "appName", "type": "str"}, + "deployment_settings": {"key": "deploymentSettings", "type": "DeploymentSettings"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "active": {"key": "active", "type": "bool"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "instances": {"key": "instances", "type": "[DeploymentInstance]"}, } def __init__( self, *, - source: Optional["UserSourceInfo"] = None, - deployment_settings: Optional["DeploymentSettings"] = None, + source: Optional["_models.UserSourceInfo"] = None, + deployment_settings: Optional["_models.DeploymentSettings"] = None, **kwargs ): """ @@ -1711,7 +1615,7 @@ def __init__( :paramtype deployment_settings: ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentSettings """ - super(DeploymentResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.app_name = None self.deployment_settings = deployment_settings @@ -1722,7 +1626,7 @@ def __init__( self.instances = None -class DeploymentSettings(msrest.serialization.Model): +class DeploymentSettings(_serialization.Model): """Deployment settings payload. :ivar cpu: Required CPU. This should be 1 for Basic tier, and in range [1, 4] for Standard @@ -1743,8 +1647,8 @@ class DeploymentSettings(msrest.serialization.Model): :vartype net_core_main_entry_path: str :ivar environment_variables: Collection of environment variables. :vartype environment_variables: dict[str, str] - :ivar runtime_version: Runtime version. Possible values include: "Java_8", "Java_11", - "NetCore_31". Default value: "Java_8". + :ivar runtime_version: Runtime version. Known values are: "Java_8", "Java_11", and + "NetCore_31". :vartype runtime_version: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.RuntimeVersion :ivar container_probe_settings: Container liveness and readiness probe settings. @@ -1753,27 +1657,30 @@ class DeploymentSettings(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'int'}, - 'memory_in_gb': {'key': 'memoryInGB', 'type': 'int'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'ResourceRequests'}, - 'jvm_options': {'key': 'jvmOptions', 'type': 'str'}, - 'net_core_main_entry_path': {'key': 'netCoreMainEntryPath', 'type': 'str'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '{str}'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, - 'container_probe_settings': {'key': 'containerProbeSettings', 'type': 'DeploymentSettingsContainerProbeSettings'}, + "cpu": {"key": "cpu", "type": "int"}, + "memory_in_gb": {"key": "memoryInGB", "type": "int"}, + "resource_requests": {"key": "resourceRequests", "type": "ResourceRequests"}, + "jvm_options": {"key": "jvmOptions", "type": "str"}, + "net_core_main_entry_path": {"key": "netCoreMainEntryPath", "type": "str"}, + "environment_variables": {"key": "environmentVariables", "type": "{str}"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, + "container_probe_settings": { + "key": "containerProbeSettings", + "type": "DeploymentSettingsContainerProbeSettings", + }, } def __init__( self, *, - cpu: Optional[int] = 1, - memory_in_gb: Optional[int] = 1, - resource_requests: Optional["ResourceRequests"] = None, + cpu: int = 1, + memory_in_gb: int = 1, + resource_requests: Optional["_models.ResourceRequests"] = None, jvm_options: Optional[str] = None, net_core_main_entry_path: Optional[str] = None, environment_variables: Optional[Dict[str, str]] = None, - runtime_version: Optional[Union[str, "RuntimeVersion"]] = "Java_8", - container_probe_settings: Optional["DeploymentSettingsContainerProbeSettings"] = None, + runtime_version: Union[str, "_models.RuntimeVersion"] = "Java_8", + container_probe_settings: Optional["_models.DeploymentSettingsContainerProbeSettings"] = None, **kwargs ): """ @@ -1796,15 +1703,15 @@ def __init__( :paramtype net_core_main_entry_path: str :keyword environment_variables: Collection of environment variables. :paramtype environment_variables: dict[str, str] - :keyword runtime_version: Runtime version. Possible values include: "Java_8", "Java_11", - "NetCore_31". Default value: "Java_8". + :keyword runtime_version: Runtime version. Known values are: "Java_8", "Java_11", and + "NetCore_31". :paramtype runtime_version: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.RuntimeVersion :keyword container_probe_settings: Container liveness and readiness probe settings. :paramtype container_probe_settings: ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentSettingsContainerProbeSettings """ - super(DeploymentSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory_in_gb = memory_in_gb self.resource_requests = resource_requests @@ -1815,7 +1722,7 @@ def __init__( self.container_probe_settings = container_probe_settings -class DeploymentSettingsContainerProbeSettings(msrest.serialization.Model): +class DeploymentSettingsContainerProbeSettings(_serialization.Model): """Container liveness and readiness probe settings. :ivar disable_probe: Indicates whether disable the liveness and readiness probe. @@ -1823,24 +1730,19 @@ class DeploymentSettingsContainerProbeSettings(msrest.serialization.Model): """ _attribute_map = { - 'disable_probe': {'key': 'disableProbe', 'type': 'bool'}, + "disable_probe": {"key": "disableProbe", "type": "bool"}, } - def __init__( - self, - *, - disable_probe: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, disable_probe: Optional[bool] = None, **kwargs): """ :keyword disable_probe: Indicates whether disable the liveness and readiness probe. :paramtype disable_probe: bool """ - super(DeploymentSettingsContainerProbeSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.disable_probe = disable_probe -class DiagnosticParameters(msrest.serialization.Model): +class DiagnosticParameters(_serialization.Model): """Diagnostic parameters of diagnostic operations. :ivar app_instance: App instance name. @@ -1852,9 +1754,9 @@ class DiagnosticParameters(msrest.serialization.Model): """ _attribute_map = { - 'app_instance': {'key': 'appInstance', 'type': 'str'}, - 'file_path': {'key': 'filePath', 'type': 'str'}, - 'duration': {'key': 'duration', 'type': 'str'}, + "app_instance": {"key": "appInstance", "type": "str"}, + "file_path": {"key": "filePath", "type": "str"}, + "duration": {"key": "duration", "type": "str"}, } def __init__( @@ -1873,13 +1775,13 @@ def __init__( :keyword duration: Duration of your JFR. 1 min can be represented by 1m or 60s. :paramtype duration: str """ - super(DiagnosticParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.app_instance = app_instance self.file_path = file_path self.duration = duration -class Error(msrest.serialization.Model): +class Error(_serialization.Model): """The error code compose of code and message. :ivar code: The code of error. @@ -1889,38 +1791,32 @@ class Error(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: The code of error. :paramtype code: str :keyword message: The message of error. :paramtype message: str """ - super(Error, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class GitPatternRepository(msrest.serialization.Model): +class GitPatternRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes """Git repository property payload. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the repository. + :ivar name: Name of the repository. Required. :vartype name: str :ivar pattern: Collection of pattern of the repository. :vartype pattern: list[str] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -1941,22 +1837,22 @@ class GitPatternRepository(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'uri': {'required': True}, + "name": {"required": True}, + "uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'pattern': {'key': 'pattern', 'type': '[str]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "pattern": {"key": "pattern", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( @@ -1976,11 +1872,11 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of the repository. + :keyword name: Name of the repository. Required. :paramtype name: str :keyword pattern: Collection of pattern of the repository. :paramtype pattern: list[str] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -1999,7 +1895,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(GitPatternRepository, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.pattern = pattern self.uri = uri @@ -2013,7 +1909,7 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ImageRegistryCredential(msrest.serialization.Model): +class ImageRegistryCredential(_serialization.Model): """Credential of the image registry. :ivar username: The username of the image registry credential. @@ -2023,36 +1919,30 @@ class ImageRegistryCredential(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - username: Optional[str] = None, - password: Optional[str] = None, - **kwargs - ): + def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs): """ :keyword username: The username of the image registry credential. :paramtype username: str :keyword password: The password of the image registry credential. :paramtype password: str """ - super(ImageRegistryCredential, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.password = password -class KeyVaultCertificateProperties(CertificateProperties): +class KeyVaultCertificateProperties(CertificateProperties): # pylint: disable=too-many-instance-attributes """Properties of certificate imported from key vault. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -2068,9 +1958,9 @@ class KeyVaultCertificateProperties(CertificateProperties): :vartype subject_name: str :ivar dns_names: The domain list of certificate. :vartype dns_names: list[str] - :ivar vault_uri: Required. The vault uri of user key vault. + :ivar vault_uri: The vault uri of user key vault. Required. :vartype vault_uri: str - :ivar key_vault_cert_name: Required. The certificate name of key vault. + :ivar key_vault_cert_name: The certificate name of key vault. Required. :vartype key_vault_cert_name: str :ivar cert_version: The certificate version of key vault. :vartype cert_version: str @@ -2080,31 +1970,31 @@ class KeyVaultCertificateProperties(CertificateProperties): """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, - 'vault_uri': {'required': True}, - 'key_vault_cert_name': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, - 'vault_uri': {'key': 'vaultUri', 'type': 'str'}, - 'key_vault_cert_name': {'key': 'keyVaultCertName', 'type': 'str'}, - 'cert_version': {'key': 'certVersion', 'type': 'str'}, - 'exclude_private_key': {'key': 'excludePrivateKey', 'type': 'bool'}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, + "vault_uri": {"required": True}, + "key_vault_cert_name": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "vault_uri": {"key": "vaultUri", "type": "str"}, + "key_vault_cert_name": {"key": "keyVaultCertName", "type": "str"}, + "cert_version": {"key": "certVersion", "type": "str"}, + "exclude_private_key": {"key": "excludePrivateKey", "type": "bool"}, } def __init__( @@ -2113,13 +2003,13 @@ def __init__( vault_uri: str, key_vault_cert_name: str, cert_version: Optional[str] = None, - exclude_private_key: Optional[bool] = False, + exclude_private_key: bool = False, **kwargs ): """ - :keyword vault_uri: Required. The vault uri of user key vault. + :keyword vault_uri: The vault uri of user key vault. Required. :paramtype vault_uri: str - :keyword key_vault_cert_name: Required. The certificate name of key vault. + :keyword key_vault_cert_name: The certificate name of key vault. Required. :paramtype key_vault_cert_name: str :keyword cert_version: The certificate version of key vault. :paramtype cert_version: str @@ -2127,20 +2017,20 @@ def __init__( vault. :paramtype exclude_private_key: bool """ - super(KeyVaultCertificateProperties, self).__init__(**kwargs) - self.type = 'KeyVaultCertificate' # type: str + super().__init__(**kwargs) + self.type = "KeyVaultCertificate" # type: str self.vault_uri = vault_uri self.key_vault_cert_name = key_vault_cert_name self.cert_version = cert_version self.exclude_private_key = exclude_private_key -class LoadedCertificate(msrest.serialization.Model): +class LoadedCertificate(_serialization.Model): """Loaded certificate payload. All required parameters must be populated in order to send to Azure. - :ivar resource_id: Required. Resource Id of loaded certificate. + :ivar resource_id: Resource Id of loaded certificate. Required. :vartype resource_id: str :ivar load_trust_store: Indicate whether the certificate will be loaded into default trust store, only work for Java runtime. @@ -2148,65 +2038,54 @@ class LoadedCertificate(msrest.serialization.Model): """ _validation = { - 'resource_id': {'required': True}, + "resource_id": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'load_trust_store': {'key': 'loadTrustStore', 'type': 'bool'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "load_trust_store": {"key": "loadTrustStore", "type": "bool"}, } - def __init__( - self, - *, - resource_id: str, - load_trust_store: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, resource_id: str, load_trust_store: bool = False, **kwargs): """ - :keyword resource_id: Required. Resource Id of loaded certificate. + :keyword resource_id: Resource Id of loaded certificate. Required. :paramtype resource_id: str :keyword load_trust_store: Indicate whether the certificate will be loaded into default trust store, only work for Java runtime. :paramtype load_trust_store: bool """ - super(LoadedCertificate, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.load_trust_store = load_trust_store -class LogFileUrlResponse(msrest.serialization.Model): +class LogFileUrlResponse(_serialization.Model): """Log file URL payload. All required parameters must be populated in order to send to Azure. - :ivar url: Required. URL of the log file. + :ivar url: URL of the log file. Required. :vartype url: str """ _validation = { - 'url': {'required': True}, + "url": {"required": True}, } _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, } - def __init__( - self, - *, - url: str, - **kwargs - ): + def __init__(self, *, url: str, **kwargs): """ - :keyword url: Required. URL of the log file. + :keyword url: URL of the log file. Required. :paramtype url: str """ - super(LogFileUrlResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url -class LogSpecification(msrest.serialization.Model): +class LogSpecification(_serialization.Model): """Specifications of the Log for Azure Monitoring. :ivar name: Name of the log. @@ -2218,9 +2097,9 @@ class LogSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, } def __init__( @@ -2239,17 +2118,17 @@ def __init__( :keyword blob_duration: Blob duration of the log. :paramtype blob_duration: str """ - super(LogSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class ManagedIdentityProperties(msrest.serialization.Model): +class ManagedIdentityProperties(_serialization.Model): """Managed identity properties retrieved from ARM request headers. - :ivar type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.ManagedIdentityType :ivar principal_id: Principal Id. :vartype principal_id: str @@ -2258,35 +2137,35 @@ class ManagedIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ManagedIdentityType"]] = None, + type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs ): """ - :keyword type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.ManagedIdentityType :keyword principal_id: Principal Id. :paramtype principal_id: str :keyword tenant_id: Tenant Id. :paramtype tenant_id: str """ - super(ManagedIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.principal_id = principal_id self.tenant_id = tenant_id -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """Specifications of the Dimension of metrics. :ivar name: Name of the dimension. @@ -2299,9 +2178,9 @@ class MetricDimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -2321,13 +2200,13 @@ def __init__( export scenario. :paramtype to_be_exported_for_shoebox: bool """ - super(MetricDimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes """Specifications of the Metrics for Azure Monitoring. :ivar name: Name of the metric. @@ -2358,17 +2237,17 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "source_mdm_namespace": {"key": "sourceMdmNamespace", "type": "str"}, } def __init__( @@ -2383,7 +2262,7 @@ def __init__( supported_aggregation_types: Optional[List[str]] = None, supported_time_grain_types: Optional[List[str]] = None, fill_gap_with_zero: Optional[bool] = None, - dimensions: Optional[List["MetricDimension"]] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, source_mdm_namespace: Optional[str] = None, **kwargs ): @@ -2414,7 +2293,7 @@ def __init__( :keyword source_mdm_namespace: Name of the MDM namespace. Optional. :paramtype source_mdm_namespace: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -2428,13 +2307,13 @@ def __init__( self.source_mdm_namespace = source_mdm_namespace -class MonitoringSettingProperties(msrest.serialization.Model): +class MonitoringSettingProperties(_serialization.Model): """Monitoring Setting properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Monitoring Setting. Possible values include: - "NotAvailable", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the Monitoring Setting. Known values are: "NotAvailable", + "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingState :ivar error: Error when apply Monitoring Setting changes. @@ -2455,27 +2334,27 @@ class MonitoringSettingProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'app_insights_sampling_rate': {'maximum': 100, 'minimum': 0}, + "provisioning_state": {"readonly": True}, + "app_insights_sampling_rate": {"maximum": 100, "minimum": 0}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'trace_enabled': {'key': 'traceEnabled', 'type': 'bool'}, - 'app_insights_instrumentation_key': {'key': 'appInsightsInstrumentationKey', 'type': 'str'}, - 'app_insights_sampling_rate': {'key': 'appInsightsSamplingRate', 'type': 'float'}, - 'app_insights_agent_versions': {'key': 'appInsightsAgentVersions', 'type': 'ApplicationInsightsAgentVersions'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "trace_enabled": {"key": "traceEnabled", "type": "bool"}, + "app_insights_instrumentation_key": {"key": "appInsightsInstrumentationKey", "type": "str"}, + "app_insights_sampling_rate": {"key": "appInsightsSamplingRate", "type": "float"}, + "app_insights_agent_versions": {"key": "appInsightsAgentVersions", "type": "ApplicationInsightsAgentVersions"}, } def __init__( self, *, - error: Optional["Error"] = None, + error: Optional["_models.Error"] = None, trace_enabled: Optional[bool] = None, app_insights_instrumentation_key: Optional[str] = None, app_insights_sampling_rate: Optional[float] = None, - app_insights_agent_versions: Optional["ApplicationInsightsAgentVersions"] = None, + app_insights_agent_versions: Optional["_models.ApplicationInsightsAgentVersions"] = None, **kwargs ): """ @@ -2495,7 +2374,7 @@ def __init__( :paramtype app_insights_agent_versions: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ApplicationInsightsAgentVersions """ - super(MonitoringSettingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.trace_enabled = trace_enabled @@ -2521,34 +2400,29 @@ class MonitoringSettingResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'MonitoringSettingProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "MonitoringSettingProperties"}, } - def __init__( - self, - *, - properties: Optional["MonitoringSettingProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.MonitoringSettingProperties"] = None, **kwargs): """ :keyword properties: Properties of the Monitoring Setting resource. :paramtype properties: ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingProperties """ - super(MonitoringSettingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class NameAvailability(msrest.serialization.Model): +class NameAvailability(_serialization.Model): """Name availability result payload. :ivar name_available: Indicates whether the name is available. @@ -2560,9 +2434,9 @@ class NameAvailability(msrest.serialization.Model): """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } def __init__( @@ -2581,52 +2455,46 @@ def __init__( :keyword message: Message why the name is not available. :paramtype message: str """ - super(NameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class NameAvailabilityParameters(msrest.serialization.Model): +class NameAvailabilityParameters(_serialization.Model): """Name availability parameters payload. All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the resource to check name availability. + :ivar type: Type of the resource to check name availability. Required. :vartype type: str - :ivar name: Required. Name to be checked. + :ivar name: Name to be checked. Required. :vartype name: str """ _validation = { - 'type': {'required': True}, - 'name': {'required': True}, + "type": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - type: str, - name: str, - **kwargs - ): + def __init__(self, *, type: str, name: str, **kwargs): """ - :keyword type: Required. Type of the resource to check name availability. + :keyword type: Type of the resource to check name availability. Required. :paramtype type: str - :keyword name: Required. Name to be checked. + :keyword name: Name to be checked. Required. :paramtype name: str """ - super(NameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class NetworkProfile(msrest.serialization.Model): +class NetworkProfile(_serialization.Model): """Service network profile payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2653,18 +2521,18 @@ class NetworkProfile(msrest.serialization.Model): """ _validation = { - 'outbound_i_ps': {'readonly': True}, - 'required_traffics': {'readonly': True}, + "outbound_i_ps": {"readonly": True}, + "required_traffics": {"readonly": True}, } _attribute_map = { - 'service_runtime_subnet_id': {'key': 'serviceRuntimeSubnetId', 'type': 'str'}, - 'app_subnet_id': {'key': 'appSubnetId', 'type': 'str'}, - 'service_cidr': {'key': 'serviceCidr', 'type': 'str'}, - 'service_runtime_network_resource_group': {'key': 'serviceRuntimeNetworkResourceGroup', 'type': 'str'}, - 'app_network_resource_group': {'key': 'appNetworkResourceGroup', 'type': 'str'}, - 'outbound_i_ps': {'key': 'outboundIPs', 'type': 'NetworkProfileOutboundIPs'}, - 'required_traffics': {'key': 'requiredTraffics', 'type': '[RequiredTraffic]'}, + "service_runtime_subnet_id": {"key": "serviceRuntimeSubnetId", "type": "str"}, + "app_subnet_id": {"key": "appSubnetId", "type": "str"}, + "service_cidr": {"key": "serviceCidr", "type": "str"}, + "service_runtime_network_resource_group": {"key": "serviceRuntimeNetworkResourceGroup", "type": "str"}, + "app_network_resource_group": {"key": "appNetworkResourceGroup", "type": "str"}, + "outbound_i_ps": {"key": "outboundIPs", "type": "NetworkProfileOutboundIPs"}, + "required_traffics": {"key": "requiredTraffics", "type": "[RequiredTraffic]"}, } def __init__( @@ -2693,7 +2561,7 @@ def __init__( Azure Spring Cloud Apps. :paramtype app_network_resource_group: str """ - super(NetworkProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_runtime_subnet_id = service_runtime_subnet_id self.app_subnet_id = app_subnet_id self.service_cidr = service_cidr @@ -2703,7 +2571,7 @@ def __init__( self.required_traffics = None -class NetworkProfileOutboundIPs(msrest.serialization.Model): +class NetworkProfileOutboundIPs(_serialization.Model): """Desired outbound IP resources for Azure Spring Cloud instance. Variables are only populated by the server, and will be ignored when sending a request. @@ -2713,24 +2581,20 @@ class NetworkProfileOutboundIPs(msrest.serialization.Model): """ _validation = { - 'public_i_ps': {'readonly': True}, + "public_i_ps": {"readonly": True}, } _attribute_map = { - 'public_i_ps': {'key': 'publicIPs', 'type': '[str]'}, + "public_i_ps": {"key": "publicIPs", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(NetworkProfileOutboundIPs, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.public_i_ps = None -class OperationDetail(msrest.serialization.Model): +class OperationDetail(_serialization.Model): """Operation detail payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2742,7 +2606,7 @@ class OperationDetail(msrest.serialization.Model): :ivar display: Display of the operation. :vartype display: ~azure.mgmt.appplatform.v2021_09_01_preview.models.OperationDisplay :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. Possible values include: "Internal". + internal only APIs. "Internal" :vartype action_type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.ActionType :ivar origin: Origin of the operation. :vartype origin: str @@ -2751,16 +2615,16 @@ class OperationDetail(msrest.serialization.Model): """ _validation = { - 'action_type': {'readonly': True}, + "action_type": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'action_type': {'key': 'actionType', 'type': 'str'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "action_type": {"key": "actionType", "type": "str"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "OperationProperties"}, } def __init__( @@ -2768,9 +2632,9 @@ 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, - properties: Optional["OperationProperties"] = None, + properties: Optional["_models.OperationProperties"] = None, **kwargs ): """ @@ -2785,7 +2649,7 @@ def __init__( :keyword properties: Properties of the operation. :paramtype properties: ~azure.mgmt.appplatform.v2021_09_01_preview.models.OperationProperties """ - super(OperationDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display @@ -2794,7 +2658,7 @@ def __init__( self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display payload. :ivar provider: Resource provider of the operation. @@ -2808,10 +2672,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__( @@ -2833,14 +2697,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 OperationProperties(msrest.serialization.Model): +class OperationProperties(_serialization.Model): """Extra Operation properties. :ivar service_specification: Service specifications of the operation. @@ -2849,25 +2713,20 @@ class OperationProperties(msrest.serialization.Model): """ _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, } - def __init__( - self, - *, - service_specification: Optional["ServiceSpecification"] = None, - **kwargs - ): + def __init__(self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs): """ :keyword service_specification: Service specifications of the operation. :paramtype service_specification: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceSpecification """ - super(OperationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_specification = service_specification -class PersistentDisk(msrest.serialization.Model): +class PersistentDisk(_serialization.Model): """Persistent disk payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2881,69 +2740,56 @@ class PersistentDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 50, 'minimum': 0}, - 'used_in_gb': {'readonly': True, 'maximum': 50, 'minimum': 0}, + "size_in_gb": {"maximum": 50, "minimum": 0}, + "used_in_gb": {"readonly": True, "maximum": 50, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'used_in_gb': {'key': 'usedInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "used_in_gb": {"key": "usedInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: Optional[str] = None, **kwargs): """ :keyword size_in_gb: Size of the persistent disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the persistent disk. :paramtype mount_path: str """ - super(PersistentDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.used_in_gb = None self.mount_path = mount_path -class RegenerateTestKeyRequestPayload(msrest.serialization.Model): +class RegenerateTestKeyRequestPayload(_serialization.Model): """Regenerate test key request payload. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :ivar key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :vartype key_type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.TestKeyType """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "TestKeyType"], - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.TestKeyType"], **kwargs): """ - :keyword key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :keyword key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :paramtype key_type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.TestKeyType """ - super(RegenerateTestKeyRequestPayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type -class RequiredTraffic(msrest.serialization.Model): +class RequiredTraffic(_serialization.Model): """Required inbound or outbound traffic for Azure Spring Cloud instance. Variables are only populated by the server, and will be ignored when sending a request. @@ -2956,34 +2802,29 @@ class RequiredTraffic(msrest.serialization.Model): :vartype ips: list[str] :ivar fqdns: The FQDN list of required traffic. :vartype fqdns: list[str] - :ivar direction: The direction of required traffic. Possible values include: "Inbound", - "Outbound". + :ivar direction: The direction of required traffic. Known values are: "Inbound" and "Outbound". :vartype direction: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.TrafficDirection """ _validation = { - 'protocol': {'readonly': True}, - 'port': {'readonly': True}, - 'ips': {'readonly': True}, - 'fqdns': {'readonly': True}, - 'direction': {'readonly': True}, + "protocol": {"readonly": True}, + "port": {"readonly": True}, + "ips": {"readonly": True}, + "fqdns": {"readonly": True}, + "direction": {"readonly": True}, } _attribute_map = { - 'protocol': {'key': 'protocol', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - 'ips': {'key': 'ips', 'type': '[str]'}, - 'fqdns': {'key': 'fqdns', 'type': '[str]'}, - 'direction': {'key': 'direction', 'type': 'str'}, + "protocol": {"key": "protocol", "type": "str"}, + "port": {"key": "port", "type": "int"}, + "ips": {"key": "ips", "type": "[str]"}, + "fqdns": {"key": "fqdns", "type": "[str]"}, + "direction": {"key": "direction", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RequiredTraffic, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.protocol = None self.port = None self.ips = None @@ -2991,7 +2832,7 @@ def __init__( self.direction = None -class ResourceRequests(msrest.serialization.Model): +class ResourceRequests(_serialization.Model): """Deployment resource request payload. :ivar cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 for @@ -3003,17 +2844,11 @@ class ResourceRequests(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - *, - cpu: Optional[str] = None, - memory: Optional[str] = None, - **kwargs - ): + def __init__(self, *, cpu: Optional[str] = None, memory: Optional[str] = None, **kwargs): """ :keyword cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 for Basic tier, and {500m, 1, 2, 3, 4} for Standard tier. @@ -3022,12 +2857,12 @@ def __init__( {512Mi, 1Gi, 2Gi} for Basic tier, and {512Mi, 1Gi, 2Gi, ..., 8Gi} for Standard tier. :paramtype memory: str """ - super(ResourceRequests, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory = memory -class ResourceSku(msrest.serialization.Model): +class ResourceSku(_serialization.Model): """Describes an available Azure Spring Cloud SKU. :ivar resource_type: Gets the type of resource the SKU applies to. @@ -3051,13 +2886,13 @@ class ResourceSku(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'SkuCapacity'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[ResourceSkuLocationInfo]'}, - 'restrictions': {'key': 'restrictions', 'type': '[ResourceSkuRestrictions]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "SkuCapacity"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[ResourceSkuLocationInfo]"}, + "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, } def __init__( @@ -3066,10 +2901,10 @@ def __init__( resource_type: Optional[str] = None, name: Optional[str] = None, tier: Optional[str] = None, - capacity: Optional["SkuCapacity"] = None, + capacity: Optional["_models.SkuCapacity"] = None, locations: Optional[List[str]] = None, - location_info: Optional[List["ResourceSkuLocationInfo"]] = None, - restrictions: Optional[List["ResourceSkuRestrictions"]] = None, + location_info: Optional[List["_models.ResourceSkuLocationInfo"]] = None, + restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None, **kwargs ): """ @@ -3092,7 +2927,7 @@ def __init__( :paramtype restrictions: list[~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceSkuRestrictions] """ - super(ResourceSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.name = name self.tier = tier @@ -3102,7 +2937,7 @@ def __init__( self.restrictions = restrictions -class ResourceSkuCapabilities(msrest.serialization.Model): +class ResourceSkuCapabilities(_serialization.Model): """ResourceSkuCapabilities. :ivar name: Gets an invariant to describe the feature. @@ -3112,29 +2947,23 @@ class ResourceSkuCapabilities(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: Gets an invariant to describe the feature. :paramtype name: str :keyword value: Gets an invariant if the feature is measured by quantity. :paramtype value: str """ - super(ResourceSkuCapabilities, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class ResourceSkuCollection(msrest.serialization.Model): +class ResourceSkuCollection(_serialization.Model): """Object that includes an array of Azure Spring Cloud SKU and a possible link for next set. :ivar value: Collection of resource SKU. @@ -3145,16 +2974,12 @@ class ResourceSkuCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ResourceSku"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ResourceSku"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of resource SKU. @@ -3163,12 +2988,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ResourceSkuCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ResourceSkuLocationInfo(msrest.serialization.Model): +class ResourceSkuLocationInfo(_serialization.Model): """Locations and availability zones where the SKU is available. :ivar location: Gets location of the SKU. @@ -3181,9 +3006,9 @@ class ResourceSkuLocationInfo(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'zone_details': {'key': 'zoneDetails', 'type': '[ResourceSkuZoneDetails]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "zone_details": {"key": "zoneDetails", "type": "[ResourceSkuZoneDetails]"}, } def __init__( @@ -3191,7 +3016,7 @@ def __init__( *, location: Optional[str] = None, zones: Optional[List[str]] = None, - zone_details: Optional[List["ResourceSkuZoneDetails"]] = None, + zone_details: Optional[List["_models.ResourceSkuZoneDetails"]] = None, **kwargs ): """ @@ -3203,13 +3028,13 @@ def __init__( :paramtype zone_details: list[~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceSkuZoneDetails] """ - super(ResourceSkuLocationInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones self.zone_details = zone_details -class ResourceSkuRestrictionInfo(msrest.serialization.Model): +class ResourceSkuRestrictionInfo(_serialization.Model): """Information about the restriction where the SKU cannot be used. :ivar locations: Gets locations where the SKU is restricted. @@ -3219,33 +3044,27 @@ class ResourceSkuRestrictionInfo(msrest.serialization.Model): """ _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - locations: Optional[List[str]] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, locations: Optional[List[str]] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword locations: Gets locations where the SKU is restricted. :paramtype locations: list[str] :keyword zones: Gets list of availability zones where the SKU is restricted. :paramtype zones: list[str] """ - super(ResourceSkuRestrictionInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.locations = locations self.zones = zones -class ResourceSkuRestrictions(msrest.serialization.Model): +class ResourceSkuRestrictions(_serialization.Model): """Restrictions where the SKU cannot be used. - :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. Known + values are: "Location" and "Zone". :vartype type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceSkuRestrictionsType :ivar values: Gets the value of restrictions. If the restriction type is set to @@ -3256,31 +3075,30 @@ class ResourceSkuRestrictions(msrest.serialization.Model): :vartype restriction_info: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceSkuRestrictionInfo :ivar reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceSkuRestrictionsReasonCode """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'ResourceSkuRestrictionInfo'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "restriction_info": {"key": "restrictionInfo", "type": "ResourceSkuRestrictionInfo"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceSkuRestrictionsType"]] = None, + type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None, values: Optional[List[str]] = None, - restriction_info: Optional["ResourceSkuRestrictionInfo"] = None, - reason_code: Optional[Union[str, "ResourceSkuRestrictionsReasonCode"]] = None, + restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None, + reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None, **kwargs ): """ :keyword type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + Known values are: "Location" and "Zone". :paramtype type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceSkuRestrictionsType :keyword values: Gets the value of restrictions. If the restriction type is set to @@ -3291,19 +3109,18 @@ def __init__( :paramtype restriction_info: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceSkuRestrictionInfo :keyword reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceSkuRestrictionsReasonCode """ - super(ResourceSkuRestrictions, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.values = values self.restriction_info = restriction_info self.reason_code = reason_code -class ResourceSkuZoneDetails(msrest.serialization.Model): +class ResourceSkuZoneDetails(_serialization.Model): """Details of capabilities available to a SKU in specific zones. :ivar name: Gets the set of zones that the SKU is available in with the @@ -3316,15 +3133,15 @@ class ResourceSkuZoneDetails(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[ResourceSkuCapabilities]'}, + "name": {"key": "name", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, } def __init__( self, *, name: Optional[List[str]] = None, - capabilities: Optional[List["ResourceSkuCapabilities"]] = None, + capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None, **kwargs ): """ @@ -3336,12 +3153,12 @@ def __init__( :paramtype capabilities: list[~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceSkuCapabilities] """ - super(ResourceSkuZoneDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.capabilities = capabilities -class ResourceUploadDefinition(msrest.serialization.Model): +class ResourceUploadDefinition(_serialization.Model): """Resource upload definition payload. :ivar relative_path: Source relative path. @@ -3351,24 +3168,18 @@ class ResourceUploadDefinition(msrest.serialization.Model): """ _attribute_map = { - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'upload_url': {'key': 'uploadUrl', 'type': 'str'}, + "relative_path": {"key": "relativePath", "type": "str"}, + "upload_url": {"key": "uploadUrl", "type": "str"}, } - def __init__( - self, - *, - relative_path: Optional[str] = None, - upload_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, relative_path: Optional[str] = None, upload_url: Optional[str] = None, **kwargs): """ :keyword relative_path: Source relative path. :paramtype relative_path: str :keyword upload_url: Upload URL. :paramtype upload_url: str """ - super(ResourceUploadDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.relative_path = relative_path self.upload_url = upload_url @@ -3386,40 +3197,33 @@ class TrackedResource(Resource): :vartype type: str :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -3437,8 +3241,7 @@ class ServiceResource(TrackedResource): :vartype type: str :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] :ivar properties: Properties of the Service resource. :vartype properties: @@ -3448,19 +3251,19 @@ class ServiceResource(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ClusterResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "ClusterResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( @@ -3468,15 +3271,15 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - properties: Optional["ClusterResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.ClusterResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] :keyword properties: Properties of the Service resource. :paramtype properties: @@ -3484,12 +3287,12 @@ def __init__( :keyword sku: Sku of the Service resource. :paramtype sku: ~azure.mgmt.appplatform.v2021_09_01_preview.models.Sku """ - super(ServiceResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.properties = properties self.sku = sku -class ServiceResourceList(msrest.serialization.Model): +class ServiceResourceList(_serialization.Model): """Object that includes an array of Service resources and a possible link for next set. :ivar value: Collection of Service resources. @@ -3500,16 +3303,12 @@ class ServiceResourceList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ServiceResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ServiceResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Service resources. @@ -3518,12 +3317,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ServiceResourceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification payload. :ivar log_specifications: Specifications of the Log for Azure Monitoring. @@ -3535,15 +3334,15 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } def __init__( self, *, - log_specifications: Optional[List["LogSpecification"]] = None, - metric_specifications: Optional[List["MetricSpecification"]] = None, + log_specifications: Optional[List["_models.LogSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -3554,12 +3353,12 @@ def __init__( :paramtype metric_specifications: list[~azure.mgmt.appplatform.v2021_09_01_preview.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_specifications = log_specifications self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """Sku of Azure Spring Cloud. :ivar name: Name of the Sku. @@ -3571,19 +3370,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Optional[str] = "S0", - tier: Optional[str] = "Standard", - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: str = "S0", tier: str = "Standard", capacity: Optional[int] = None, **kwargs): """ :keyword name: Name of the Sku. :paramtype name: str @@ -3592,37 +3384,37 @@ def __init__( :keyword capacity: Current capacity of the target resource. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SkuCapacity(msrest.serialization.Model): +class SkuCapacity(_serialization.Model): """The SKU capacity. All required parameters must be populated in order to send to Azure. - :ivar minimum: Required. Gets or sets the minimum. + :ivar minimum: Gets or sets the minimum. Required. :vartype minimum: int :ivar maximum: Gets or sets the maximum. :vartype maximum: int :ivar default: Gets or sets the default. :vartype default: int - :ivar scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :ivar scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", and + "Automatic". :vartype scale_type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.SkuScaleType """ _validation = { - 'minimum': {'required': True}, + "minimum": {"required": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } def __init__( @@ -3631,59 +3423,52 @@ def __init__( minimum: int, maximum: Optional[int] = None, default: Optional[int] = None, - scale_type: Optional[Union[str, "SkuScaleType"]] = None, + scale_type: Optional[Union[str, "_models.SkuScaleType"]] = None, **kwargs ): """ - :keyword minimum: Required. Gets or sets the minimum. + :keyword minimum: Gets or sets the minimum. Required. :paramtype minimum: int :keyword maximum: Gets or sets the maximum. :paramtype maximum: int :keyword default: Gets or sets the default. :paramtype default: int - :keyword scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :keyword scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", + and "Automatic". :paramtype scale_type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.SkuScaleType """ - super(SkuCapacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.minimum = minimum self.maximum = maximum self.default = default self.scale_type = scale_type -class StorageProperties(msrest.serialization.Model): +class StorageProperties(_serialization.Model): """Storage resource payload. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: StorageAccount. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + StorageAccount All required parameters must be populated in order to send to Azure. - :ivar storage_type: Required. The type of the storage.Constant filled by server. Possible - values include: "StorageAccount". + :ivar storage_type: The type of the storage. Required. "StorageAccount" :vartype storage_type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageType """ _validation = { - 'storage_type': {'required': True}, + "storage_type": {"required": True}, } _attribute_map = { - 'storage_type': {'key': 'storageType', 'type': 'str'}, + "storage_type": {"key": "storageType", "type": "str"}, } - _subtype_map = { - 'storage_type': {'StorageAccount': 'StorageAccount'} - } + _subtype_map = {"storage_type": {"StorageAccount": "StorageAccount"}} - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.storage_type = None # type: Optional[str] @@ -3692,42 +3477,35 @@ class StorageAccount(StorageProperties): All required parameters must be populated in order to send to Azure. - :ivar storage_type: Required. The type of the storage.Constant filled by server. Possible - values include: "StorageAccount". + :ivar storage_type: The type of the storage. Required. "StorageAccount" :vartype storage_type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageType - :ivar account_name: Required. The account name of the Azure Storage Account. + :ivar account_name: The account name of the Azure Storage Account. Required. :vartype account_name: str - :ivar account_key: Required. The account key of the Azure Storage Account. + :ivar account_key: The account key of the Azure Storage Account. Required. :vartype account_key: str """ _validation = { - 'storage_type': {'required': True}, - 'account_name': {'required': True}, - 'account_key': {'required': True}, + "storage_type": {"required": True}, + "account_name": {"required": True}, + "account_key": {"required": True}, } _attribute_map = { - 'storage_type': {'key': 'storageType', 'type': 'str'}, - 'account_name': {'key': 'accountName', 'type': 'str'}, - 'account_key': {'key': 'accountKey', 'type': 'str'}, + "storage_type": {"key": "storageType", "type": "str"}, + "account_name": {"key": "accountName", "type": "str"}, + "account_key": {"key": "accountKey", "type": "str"}, } - def __init__( - self, - *, - account_name: str, - account_key: str, - **kwargs - ): + def __init__(self, *, account_name: str, account_key: str, **kwargs): """ - :keyword account_name: Required. The account name of the Azure Storage Account. + :keyword account_name: The account name of the Azure Storage Account. Required. :paramtype account_name: str - :keyword account_key: Required. The account key of the Azure Storage Account. + :keyword account_key: The account key of the Azure Storage Account. Required. :paramtype account_key: str """ - super(StorageAccount, self).__init__(**kwargs) - self.storage_type = 'StorageAccount' # type: str + super().__init__(**kwargs) + self.storage_type = "StorageAccount" # type: str self.account_name = account_name self.account_key = account_key @@ -3750,36 +3528,31 @@ class StorageResource(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'}, - 'properties': {'key': 'properties', 'type': 'StorageProperties'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "StorageProperties"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - *, - properties: Optional["StorageProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.StorageProperties"] = None, **kwargs): """ :keyword properties: Properties of the storage resource payload. :paramtype properties: ~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageProperties """ - super(StorageResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.system_data = None -class StorageResourceCollection(msrest.serialization.Model): +class StorageResourceCollection(_serialization.Model): """Collection compose of storage resources list and a possible link for next page. :ivar value: The storage resources list. @@ -3789,16 +3562,12 @@ class StorageResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["StorageResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.StorageResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The storage resources list. @@ -3806,19 +3575,19 @@ def __init__( :keyword next_link: The link to next page of storage list. :paramtype next_link: str """ - super(StorageResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SupportedRuntimeVersion(msrest.serialization.Model): +class SupportedRuntimeVersion(_serialization.Model): """Supported deployment runtime version descriptor. - :ivar value: The raw value which could be passed to deployment CRUD operations. Possible values - include: "Java_8", "Java_11", "NetCore_31". + :ivar value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", and "NetCore_31". :vartype value: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.SupportedRuntimeValue - :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). Known + values are: "Java" and ".NET Core". :vartype platform: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.SupportedRuntimePlatform :ivar version: The detailed version (major.minor) of the platform. @@ -3826,52 +3595,52 @@ class SupportedRuntimeVersion(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'platform': {'key': 'platform', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "platform": {"key": "platform", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - value: Optional[Union[str, "SupportedRuntimeValue"]] = None, - platform: Optional[Union[str, "SupportedRuntimePlatform"]] = None, + value: Optional[Union[str, "_models.SupportedRuntimeValue"]] = None, + platform: Optional[Union[str, "_models.SupportedRuntimePlatform"]] = None, version: Optional[str] = None, **kwargs ): """ - :keyword value: The raw value which could be passed to deployment CRUD operations. Possible - values include: "Java_8", "Java_11", "NetCore_31". + :keyword value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", and "NetCore_31". :paramtype value: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.SupportedRuntimeValue :keyword platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + Known values are: "Java" and ".NET Core". :paramtype platform: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.SupportedRuntimePlatform :keyword version: The detailed version (major.minor) of the platform. :paramtype version: str """ - super(SupportedRuntimeVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.platform = platform self.version = version -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.appplatform.v2021_09_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -3879,44 +3648,44 @@ class SystemData(msrest.serialization.Model): """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "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.appplatform.v2021_09_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.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 @@ -3925,7 +3694,7 @@ def __init__( self.last_modified_at = last_modified_at -class TemporaryDisk(msrest.serialization.Model): +class TemporaryDisk(_serialization.Model): """Temporary disk payload. :ivar size_in_gb: Size of the temporary disk in GB. @@ -3935,33 +3704,27 @@ class TemporaryDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 5, 'minimum': 0}, + "size_in_gb": {"maximum": 5, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = "/tmp", - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: str = "/tmp", **kwargs): """ :keyword size_in_gb: Size of the temporary disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the temporary disk. :paramtype mount_path: str """ - super(TemporaryDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.mount_path = mount_path -class TestKeys(msrest.serialization.Model): +class TestKeys(_serialization.Model): """Test keys payload. :ivar primary_key: Primary key. @@ -3977,11 +3740,11 @@ class TestKeys(msrest.serialization.Model): """ _attribute_map = { - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'primary_test_endpoint': {'key': 'primaryTestEndpoint', 'type': 'str'}, - 'secondary_test_endpoint': {'key': 'secondaryTestEndpoint', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "primary_test_endpoint": {"key": "primaryTestEndpoint", "type": "str"}, + "secondary_test_endpoint": {"key": "secondaryTestEndpoint", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, } def __init__( @@ -4006,7 +3769,7 @@ def __init__( :keyword enabled: Indicates whether the test endpoint feature enabled or not. :paramtype enabled: bool """ - super(TestKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_key = primary_key self.secondary_key = secondary_key self.primary_test_endpoint = primary_test_endpoint @@ -4014,11 +3777,11 @@ def __init__( self.enabled = enabled -class UserSourceInfo(msrest.serialization.Model): +class UserSourceInfo(_serialization.Model): """Source information for a deployment. - :ivar type: Type of the source uploaded. Possible values include: "Jar", "NetCoreZip", - "Source", "Container". + :ivar type: Type of the source uploaded. Known values are: "Jar", "NetCoreZip", "Source", and + "Container". :vartype type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.UserSourceType :ivar relative_path: Relative path of the storage which stores the source. :vartype relative_path: str @@ -4033,26 +3796,26 @@ class UserSourceInfo(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'artifact_selector': {'key': 'artifactSelector', 'type': 'str'}, - 'custom_container': {'key': 'customContainer', 'type': 'CustomContainer'}, + "type": {"key": "type", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "artifact_selector": {"key": "artifactSelector", "type": "str"}, + "custom_container": {"key": "customContainer", "type": "CustomContainer"}, } def __init__( self, *, - type: Optional[Union[str, "UserSourceType"]] = None, + type: Optional[Union[str, "_models.UserSourceType"]] = None, relative_path: Optional[str] = None, version: Optional[str] = None, artifact_selector: Optional[str] = None, - custom_container: Optional["CustomContainer"] = None, + custom_container: Optional["_models.CustomContainer"] = None, **kwargs ): """ - :keyword type: Type of the source uploaded. Possible values include: "Jar", "NetCoreZip", - "Source", "Container". + :keyword type: Type of the source uploaded. Known values are: "Jar", "NetCoreZip", "Source", + and "Container". :paramtype type: str or ~azure.mgmt.appplatform.v2021_09_01_preview.models.UserSourceType :keyword relative_path: Relative path of the storage which stores the source. :paramtype relative_path: str @@ -4065,7 +3828,7 @@ def __init__( :keyword custom_container: Custom container payload. :paramtype custom_container: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomContainer """ - super(UserSourceInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.relative_path = relative_path self.version = version diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/__init__.py index 97c71859bbd5..4ad7e9cd57be 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/__init__.py @@ -19,17 +19,23 @@ from ._runtime_versions_operations import RuntimeVersionsOperations from ._skus_operations import SkusOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'StoragesOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', + "ServicesOperations", + "ConfigServersOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "StoragesOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_apps_operations.py index 3a98683cb522..3f7a9f8e715a 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_apps_operations.py @@ -6,341 +6,313 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, sync_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 sync_status is not None: - _query_parameters['syncStatus'] = _SERIALIZER.query("sync_status", sync_status, 'str') + _params["syncStatus"] = _SERIALIZER.query("sync_status", sync_status, "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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str +def build_list_request(resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_resource_upload_url_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_validate_domain_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class AppsOperations(object): - """AppsOperations 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.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.AppPlatformManagementClient`'s + :attr:`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 get( @@ -350,102 +322,125 @@ def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -453,21 +448,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -475,20 +549,24 @@ def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -501,84 +579,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -588,25 +677,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -618,83 +702,107 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -702,18 +810,97 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -721,20 +908,24 @@ def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -747,104 +938,120 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AppResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -858,10 +1065,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 @@ -871,74 +1076,138 @@ 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.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def validate_domain( @@ -946,67 +1215,86 @@ def validate_domain( resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: Union[_models.CustomDomainValidatePayload, IO], **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. :type validate_payload: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainValidatePayload + ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_bindings_operations.py index 8c7a874dc795..ac210e37686e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_bindings_operations.py @@ -6,330 +6,310 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class BindingsOperations(object): - """BindingsOperations 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.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +317,55 @@ def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -377,21 +373,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +481,27 @@ def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +514,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +536,75 @@ def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -518,28 +614,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -551,46 +641,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _update_initial( self, @@ -598,39 +696,55 @@ def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -638,18 +752,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +857,27 @@ def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +890,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +912,104 @@ def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +1023,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 @@ -816,8 +1034,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_certificates_operations.py index 8c74b0b71239..3744d6595cca 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_certificates_operations.py @@ -6,308 +6,317 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - 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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 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.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", 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.appplatform.v2021_09_01_preview.AppPlatformManagementClient`'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 get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(certificate_resource, 'CertificateResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -315,21 +324,101 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -337,21 +426,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> LROPoller["_models.CertificateResource"]: + ) -> LROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type certificate_resource: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource + ~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -364,84 +457,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -451,25 +555,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -481,98 +580,117 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +704,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 @@ -599,8 +715,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_config_servers_operations.py index fa97da75ec50..83ee717c6f8b 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_config_servers_operations.py @@ -6,311 +6,311 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_validate_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ConfigServersOperations(object): - """ConfigServersOperations 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.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -318,37 +318,115 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -361,86 +439,109 @@ def begin_update_put( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -448,37 +549,115 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -491,86 +670,109 @@ def begin_update_patch( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_settings, 'ConfigServerSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -578,37 +780,115 @@ def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerSettings + ~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -621,47 +901,54 @@ def begin_validate( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_custom_domains_operations.py index f43ae67ea773..b31698c6757c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_custom_domains_operations.py @@ -6,330 +6,310 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class CustomDomainsOperations(object): - """CustomDomainsOperations 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.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +317,55 @@ def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -377,21 +373,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +481,27 @@ def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +514,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +536,75 @@ def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -518,28 +614,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -551,46 +641,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _update_initial( self, @@ -598,39 +696,55 @@ def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -638,18 +752,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +857,27 @@ def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +890,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +912,105 @@ def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +1024,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 @@ -816,8 +1035,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_deployments_operations.py index 223809019340..a29e4aad5b84 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_deployments_operations.py @@ -6,678 +6,667 @@ # Code generated 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, List, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_delete_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_for_cluster_request( - subscription_id: str, resource_group_name: str, service_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_start_request_initial( - subscription_id: str, +def build_start_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_stop_request_initial( - subscription_id: str, +def build_stop_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request_initial( - subscription_id: str, +def build_restart_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_get_log_file_url_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_generate_heap_dump_request_initial( - subscription_id: str, +def build_generate_heap_dump_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_generate_thread_dump_request_initial( - subscription_id: str, +def build_generate_thread_dump_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_start_jfr_request_initial( - subscription_id: str, +def build_start_jfr_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/StartJFR") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/StartJFR", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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 DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations 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.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( self, @@ -685,39 +674,55 @@ def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -725,21 +730,107 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -748,23 +839,27 @@ def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -777,19 +872,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -797,67 +894,75 @@ def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -867,28 +972,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -900,46 +999,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _update_initial( self, @@ -947,39 +1054,55 @@ def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -987,18 +1110,104 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -1007,23 +1216,27 @@ def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1036,19 +1249,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -1056,32 +1271,37 @@ def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -1091,60 +1311,72 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + ) -> Iterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1158,10 +1390,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 @@ -1171,69 +1401,76 @@ 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1247,10 +1484,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 @@ -1260,46 +1495,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1309,28 +1545,22 @@ def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1342,81 +1572,92 @@ def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1426,28 +1667,22 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1459,81 +1694,92 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -1543,28 +1789,22 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace - def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1576,98 +1816,109 @@ def begin_restart( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1676,15 +1927,14 @@ def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1692,39 +1942,55 @@ def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statemen service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_heap_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_heap_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_heap_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_heap_dump_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]: @@ -1734,33 +2000,119 @@ def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _generate_heap_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + _generate_heap_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + @overload + def begin_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_heap_dump( # pylint: disable=inconsistent-return-statements + def begin_generate_heap_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Generate Heap Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1771,19 +2123,21 @@ def begin_generate_heap_dump( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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._generate_heap_dump_initial( + raw_result = self._generate_heap_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1791,29 +2145,35 @@ def begin_generate_heap_dump( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_generate_heap_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + begin_generate_heap_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1821,39 +2181,55 @@ def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statem service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_thread_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_thread_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_thread_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_thread_dump_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]: @@ -1863,33 +2239,119 @@ def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _generate_thread_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + _generate_thread_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + @overload + def begin_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_thread_dump( # pylint: disable=inconsistent-return-statements + def begin_generate_thread_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Generate Thread Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1900,19 +2362,21 @@ def begin_generate_thread_dump( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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._generate_thread_dump_initial( + raw_result = self._generate_thread_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1920,29 +2384,35 @@ def begin_generate_thread_dump( # pylint: disable=inconsistent-return-statement diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_generate_thread_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + begin_generate_thread_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore def _start_jfr_initial( # pylint: disable=inconsistent-return-statements self, @@ -1950,39 +2420,55 @@ def _start_jfr_initial( # pylint: disable=inconsistent-return-statements service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_start_jfr_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_start_jfr_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._start_jfr_initial.metadata['url'], + content=_content, + template_url=self._start_jfr_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]: @@ -1992,33 +2478,119 @@ def _start_jfr_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_jfr_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/StartJFR"} # type: ignore + _start_jfr_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/StartJFR"} # type: ignore + @overload + def begin_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_start_jfr( # pylint: disable=inconsistent-return-statements + def begin_start_jfr( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Start JFR. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2021_09_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2029,19 +2601,21 @@ def begin_start_jfr( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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._start_jfr_initial( + raw_result = self._start_jfr_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -2049,26 +2623,32 @@ def begin_start_jfr( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start_jfr.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/StartJFR"} # type: ignore + begin_start_jfr.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/StartJFR"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_monitoring_settings_operations.py index 268cadda3125..4b6eebef90d0 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_monitoring_settings_operations.py @@ -6,267 +6,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 MonitoringSettingsOperations(object): - """MonitoringSettingsOperations 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.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -274,37 +282,115 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -317,86 +403,109 @@ def begin_update_put( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -404,37 +513,115 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation 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,47 +634,54 @@ def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_operations.py index ca281fa37d2c..2d4e57c7f427 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_operations.py @@ -6,111 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - accept = "application/json" +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/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.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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.appplatform.v2021_09_01_preview.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,10 +147,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 +158,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_runtime_versions_operations.py index 77be28c973b3..c13652dc3fc7 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_runtime_versions_operations.py @@ -6,117 +6,128 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from 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 -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_runtime_versions_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - accept = "application/json" +def build_list_runtime_versions_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/runtimeVersions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 RuntimeVersionsOperations(object): - """RuntimeVersionsOperations 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.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_services_operations.py index a3277b6014ea..432f28dec095 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_services_operations.py @@ -6,636 +6,594 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_test_keys_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_regenerate_test_key_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/regenerateTestKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_disable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_enable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_stop_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_stop_request(resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_start_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_check_name_availability_request( - subscription_id: str, - location: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "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 - ) - - -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 ServicesOperations(object): - """ServicesOperations 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.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -643,39 +601,43 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -688,81 +650,162 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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 [202, 204]: @@ -772,22 +815,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -799,80 +836,100 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -880,36 +937,40 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -922,220 +983,379 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2021_09_01_preview.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2021_09_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -1145,98 +1365,104 @@ def disable_test_endpoint( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace - def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def enable_test_endpoint(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1246,22 +1472,16 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_stop(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Stop a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -1273,75 +1493,88 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1351,22 +1584,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_start(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Start a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -1378,147 +1605,229 @@ def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - @distributed_trace + @overload def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2021_09_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2021_09_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(availability_parameters, 'NameAvailabilityParameters') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1532,10 +1841,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 @@ -1545,58 +1852,68 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1610,10 +1927,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 @@ -1623,8 +1938,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_skus_operations.py index 171bbd6fa209..39723e170e86 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_skus_operations.py @@ -6,120 +6,140 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 SkusOperations(object): - """SkusOperations 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.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) + :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -133,10 +153,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 @@ -146,8 +164,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_storages_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_storages_operations.py index d3fc54c14be7..67cc27387b9a 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_storages_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2021_09_01_preview/operations/_storages_operations.py @@ -6,308 +6,317 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - storage_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, service_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - 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, - service_name: str, - storage_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, service_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 StoragesOperations(object): - """StoragesOperations 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.appplatform.v2021_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class StoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2021_09_01_preview.AppPlatformManagementClient`'s + :attr:`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 get( - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any - ) -> "_models.StorageResource": + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> _models.StorageResource: """Get the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageResource, or the result of cls(response) + :return: StorageResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> "_models.StorageResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] + ) -> _models.StorageResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(storage_resource, 'StorageResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_resource, (IO, bytes)): + _content = storage_resource + else: + _json = self._serialize.body(storage_resource, "StorageResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -315,21 +324,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: _models.StorageResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -337,20 +425,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> LROPoller["_models.StorageResource"]: + ) -> LROPoller[_models.StorageResource]: """Create or update storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str - :param storage_resource: Parameters for the create or update operation. - :type storage_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource + :param storage_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -363,84 +456,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + 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, service_name=service_name, storage_name=storage_name, storage_resource=storage_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, storage_name=storage_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]: @@ -450,25 +554,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_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. @@ -480,98 +579,115 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + 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, service_name=service_name, storage_name=storage_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.StorageResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.StorageResource"]: """List all the storages of one Azure Spring Cloud instance. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageResourceCollection or the result of - cls(response) + :return: An iterator like instance of either StorageResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2021_09_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # 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", "2021-09-01-preview") + ) # type: Literal["2021-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -585,10 +701,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 @@ -598,8 +712,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/__init__.py index 41ec6d71ff7f..a6bfaa2de14d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_app_platform_management_client.py index 4633ae192d4c..9e1d7feabe0f 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_app_platform_management_client.py @@ -9,20 +9,44 @@ 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 .._serialization import Deserializer, Serializer from ._configuration import AppPlatformManagementClientConfiguration -from .operations import ApiPortalCustomDomainsOperations, ApiPortalsOperations, AppsOperations, BindingsOperations, BuildServiceAgentPoolOperations, BuildServiceBuilderOperations, BuildServiceOperations, BuildpackBindingOperations, CertificatesOperations, ConfigServersOperations, ConfigurationServicesOperations, CustomDomainsOperations, DeploymentsOperations, GatewayCustomDomainsOperations, GatewayRouteConfigsOperations, GatewaysOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServiceRegistriesOperations, ServicesOperations, SkusOperations, StoragesOperations +from .operations import ( + ApiPortalCustomDomainsOperations, + ApiPortalsOperations, + AppsOperations, + BindingsOperations, + BuildServiceAgentPoolOperations, + BuildServiceBuilderOperations, + BuildServiceOperations, + BuildpackBindingOperations, + CertificatesOperations, + ConfigServersOperations, + ConfigurationServicesOperations, + CustomDomainsOperations, + DeploymentsOperations, + GatewayCustomDomainsOperations, + GatewayRouteConfigsOperations, + GatewaysOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServiceRegistriesOperations, + ServicesOperations, + SkusOperations, + StoragesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Cloud. :ivar services: ServicesOperations operations @@ -87,10 +111,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib :ivar api_portal_custom_domains: ApiPortalCustomDomainsOperations operations :vartype api_portal_custom_domains: azure.mgmt.appplatform.v2022_01_01_preview.operations.ApiPortalCustomDomainsOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -108,7 +132,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -117,13 +143,25 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.configuration_services = ConfigurationServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.service_registries = ServiceRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_services = ConfigurationServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_registries = ServiceRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.build_service = BuildServiceOperations(self._client, self._config, self._serialize, self._deserialize) - self.buildpack_binding = BuildpackBindingOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_builder = BuildServiceBuilderOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_agent_pool = BuildServiceAgentPoolOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.buildpack_binding = BuildpackBindingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_builder = BuildServiceBuilderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_agent_pool = BuildServiceAgentPoolOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.storages = StoragesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -131,20 +169,23 @@ def __init__( self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.gateways = GatewaysOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_route_configs = GatewayRouteConfigsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_custom_domains = GatewayCustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_route_configs = GatewayRouteConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gateway_custom_domains = GatewayCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.api_portals = ApiPortalsOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_portal_custom_domains = ApiPortalCustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.api_portal_custom_domains = ApiPortalCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -153,7 +194,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_configuration.py index 62fe7927765f..eda1e20c7f80 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + api_version = kwargs.pop("api_version", "2022-01-01-preview") # type: Literal["2022-01-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_metadata.json b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_metadata.json index 3c866e52e065..7ca737efa299 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_metadata.json +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}, \"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\": [\"AppPlatformManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -121,4 +121,4 @@ "api_portals": "ApiPortalsOperations", "api_portal_custom_domains": "ApiPortalCustomDomainsOperations" } -} \ No newline at end of file +} diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_vendor.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_vendor.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_version.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_version.py index e7ffc58c0429..92453d8691d9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_version.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.1.0" +VERSION = "6.1.0" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/__init__.py index 44ce4a5043f8..398c48287ad8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._app_platform_management_client import AppPlatformManagementClient -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/_app_platform_management_client.py index 1a8e1445d17b..0a0414152700 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/_app_platform_management_client.py @@ -9,20 +9,44 @@ 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 AppPlatformManagementClientConfiguration -from .operations import ApiPortalCustomDomainsOperations, ApiPortalsOperations, AppsOperations, BindingsOperations, BuildServiceAgentPoolOperations, BuildServiceBuilderOperations, BuildServiceOperations, BuildpackBindingOperations, CertificatesOperations, ConfigServersOperations, ConfigurationServicesOperations, CustomDomainsOperations, DeploymentsOperations, GatewayCustomDomainsOperations, GatewayRouteConfigsOperations, GatewaysOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServiceRegistriesOperations, ServicesOperations, SkusOperations, StoragesOperations +from .operations import ( + ApiPortalCustomDomainsOperations, + ApiPortalsOperations, + AppsOperations, + BindingsOperations, + BuildServiceAgentPoolOperations, + BuildServiceBuilderOperations, + BuildServiceOperations, + BuildpackBindingOperations, + CertificatesOperations, + ConfigServersOperations, + ConfigurationServicesOperations, + CustomDomainsOperations, + DeploymentsOperations, + GatewayCustomDomainsOperations, + GatewayRouteConfigsOperations, + GatewaysOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServiceRegistriesOperations, + ServicesOperations, + SkusOperations, + StoragesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Cloud. :ivar services: ServicesOperations operations @@ -87,10 +111,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib :ivar api_portal_custom_domains: ApiPortalCustomDomainsOperations operations :vartype api_portal_custom_domains: azure.mgmt.appplatform.v2022_01_01_preview.aio.operations.ApiPortalCustomDomainsOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -108,7 +132,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -117,13 +143,25 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.configuration_services = ConfigurationServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.service_registries = ServiceRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_services = ConfigurationServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_registries = ServiceRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.build_service = BuildServiceOperations(self._client, self._config, self._serialize, self._deserialize) - self.buildpack_binding = BuildpackBindingOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_builder = BuildServiceBuilderOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_agent_pool = BuildServiceAgentPoolOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.buildpack_binding = BuildpackBindingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_builder = BuildServiceBuilderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_agent_pool = BuildServiceAgentPoolOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.storages = StoragesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -131,20 +169,23 @@ def __init__( self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.gateways = GatewaysOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_route_configs = GatewayRouteConfigsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_custom_domains = GatewayCustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_route_configs = GatewayRouteConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gateway_custom_domains = GatewayCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.api_portals = ApiPortalsOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_portal_custom_domains = ApiPortalCustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.api_portal_custom_domains = ApiPortalCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -153,7 +194,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/_configuration.py index 7b9398e33727..0d7df0032c77 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + api_version = kwargs.pop("api_version", "2022-01-01-preview") # type: Literal["2022-01-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/__init__.py index 0da100b4246c..57694a8d82f6 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/__init__.py @@ -30,28 +30,34 @@ from ._api_portals_operations import ApiPortalsOperations from ._api_portal_custom_domains_operations import ApiPortalCustomDomainsOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'ConfigurationServicesOperations', - 'ServiceRegistriesOperations', - 'BuildServiceOperations', - 'BuildpackBindingOperations', - 'BuildServiceBuilderOperations', - 'BuildServiceAgentPoolOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'StoragesOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', - 'GatewaysOperations', - 'GatewayRouteConfigsOperations', - 'GatewayCustomDomainsOperations', - 'ApiPortalsOperations', - 'ApiPortalCustomDomainsOperations', + "ServicesOperations", + "ConfigServersOperations", + "ConfigurationServicesOperations", + "ServiceRegistriesOperations", + "BuildServiceOperations", + "BuildpackBindingOperations", + "BuildServiceBuilderOperations", + "BuildServiceAgentPoolOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "StoragesOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", + "GatewaysOperations", + "GatewayRouteConfigsOperations", + "GatewayCustomDomainsOperations", + "ApiPortalsOperations", + "ApiPortalCustomDomainsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_api_portal_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_api_portal_custom_domains_operations.py index 2147a0e1dea9..2006a155b100 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_api_portal_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_api_portal_custom_domains_operations.py @@ -6,113 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_portal_custom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._api_portal_custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiPortalCustomDomainsOperations: - """ApiPortalCustomDomainsOperations 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 ApiPortalCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`api_portal_custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.ApiPortalCustomDomainResource": + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any + ) -> _models.ApiPortalCustomDomainResource: """Get the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiPortalCustomDomainResource, or the result of cls(response) + :return: ApiPortalCustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +140,55 @@ async def _create_or_update_initial( service_name: str, api_portal_name: str, domain_name: str, - api_portal_custom_domain_resource: "_models.ApiPortalCustomDomainResource", + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], **kwargs: Any - ) -> "_models.ApiPortalCustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] + ) -> _models.ApiPortalCustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(api_portal_custom_domain_resource, 'ApiPortalCustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_custom_domain_resource, (IO, bytes)): + _content = api_portal_custom_domain_resource + else: + _json = self._serialize.body(api_portal_custom_domain_resource, "ApiPortalCustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: @@ -160,18 +196,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: _models.ApiPortalCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,24 +304,27 @@ async def begin_create_or_update( service_name: str, api_portal_name: str, domain_name: str, - api_portal_custom_domain_resource: "_models.ApiPortalCustomDomainResource", + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ApiPortalCustomDomainResource"]: + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: """Create or update the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_name: str :param api_portal_custom_domain_resource: The API portal custom domain for the create or update - operation. + operation. Is either a model type or a IO type. Required. :type api_portal_custom_domain_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -210,19 +337,21 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + 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, service_name=service_name, api_portal_name=api_portal_name, @@ -230,67 +359,76 @@ async def begin_create_or_update( api_portal_custom_domain_resource=api_portal_custom_domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: @@ -300,28 +438,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_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. @@ -333,104 +465,123 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ApiPortalCustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApiPortalCustomDomainResource"]: """Handle requests to list all API portal custom domains. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiPortalCustomDomainResourceCollection or the - result of cls(response) + :return: An iterator like instance of either ApiPortalCustomDomainResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, api_portal_name=api_portal_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, - service_name=service_name, - api_portal_name=api_portal_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -444,10 +595,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 @@ -457,8 +606,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_api_portals_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_api_portals_operations.py index 86e7e4d35b48..21f8be478630 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_api_portals_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_api_portals_operations.py @@ -6,147 +6,185 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_portals_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_validate_domain_request -T = TypeVar('T') +from ...operations._api_portals_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiPortalsOperations: - """ApiPortalsOperations 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 ApiPortalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`api_portals` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any - ) -> "_models.ApiPortalResource": + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> _models.ApiPortalResource: """Get the API portal and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiPortalResource, or the result of cls(response) + :return: ApiPortalResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, api_portal_name: str, - api_portal_resource: "_models.ApiPortalResource", + api_portal_resource: Union[_models.ApiPortalResource, IO], **kwargs: Any - ) -> "_models.ApiPortalResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] + ) -> _models.ApiPortalResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(api_portal_resource, 'ApiPortalResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_resource, (IO, bytes)): + _content = api_portal_resource + else: + _json = self._serialize.body(api_portal_resource, "ApiPortalResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: @@ -154,18 +192,97 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: _models.ApiPortalResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -173,20 +290,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, api_portal_name: str, - api_portal_resource: "_models.ApiPortalResource", + api_portal_resource: Union[_models.ApiPortalResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ApiPortalResource"]: + ) -> AsyncLROPoller[_models.ApiPortalResource]: """Create the default API portal or update the existing API portal. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param api_portal_resource: The API portal for the create or update operation. + :param api_portal_resource: The API portal for the create or update operation. Is either a + model type or a IO type. Required. :type api_portal_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -199,84 +321,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + 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, service_name=service_name, api_portal_name=api_portal_name, api_portal_resource=api_portal_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, api_portal_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: @@ -286,25 +420,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the default API portal. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -316,98 +445,118 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, api_portal_name=api_portal_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ApiPortalResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApiPortalResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiPortalResourceCollection or the result of - cls(response) + :return: An iterator like instance of either ApiPortalResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -421,10 +570,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 @@ -434,79 +581,159 @@ 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.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore - @distributed_trace_async + @overload async def validate_domain( self, resource_group_name: str, service_name: str, api_portal_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the domains are valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_apps_operations.py index d1acb17b8fd0..e9a6d3a3407f 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_apps_operations.py @@ -6,46 +6,68 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._apps_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_get_resource_upload_url_request, build_list_request, build_set_active_deployments_request_initial, build_update_request_initial, build_validate_domain_request -T = TypeVar('T') +from ...operations._apps_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_get_resource_upload_url_request, + build_list_request, + build_set_active_deployments_request, + build_update_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AppsOperations: - """AppsOperations 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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`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_async async def get( @@ -55,102 +77,125 @@ async def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -158,21 +203,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,20 +304,24 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -206,84 +334,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -293,25 +433,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -323,83 +458,108 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -407,18 +567,97 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -426,20 +665,24 @@ async def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -452,104 +695,121 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncIterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AppResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -563,10 +823,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 @@ -576,112 +834,129 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace_async async def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore async def _set_active_deployments_initial( self, resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(active_deployment_collection, 'ActiveDeploymentCollection') - - request = build_set_active_deployments_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(active_deployment_collection, (IO, bytes)): + _content = active_deployment_collection + else: + _json = self._serialize.body(active_deployment_collection, "ActiveDeploymentCollection") + + request = build_set_active_deployments_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._set_active_deployments_initial.metadata['url'], + content=_content, + template_url=self._set_active_deployments_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]: @@ -689,18 +964,98 @@ async def _set_active_deployments_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _set_active_deployments_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + _set_active_deployments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + + @overload + async def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: _models.ActiveDeploymentCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ActiveDeploymentCollection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_set_active_deployments( @@ -708,21 +1063,25 @@ async def begin_set_active_deployments( resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Set existing Deployment under the app as active. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param active_deployment_collection: A list of Deployment name to be active. + :param active_deployment_collection: A list of Deployment name to be active. Is either a model + type or a IO type. Required. :type active_deployment_collection: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.ActiveDeploymentCollection + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ActiveDeploymentCollection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -735,119 +1094,209 @@ async def begin_set_active_deployments( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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._set_active_deployments_initial( + raw_result = await self._set_active_deployments_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, active_deployment_collection=active_deployment_collection, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_set_active_deployments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + begin_set_active_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore - @distributed_trace_async + @overload async def validate_domain( self, resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_bindings_operations.py index 028f51b987f7..7b7d999358ce 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_bindings_operations.py @@ -6,113 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._bindings_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._bindings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BindingsOperations: - """BindingsOperations 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 BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +141,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -160,21 +197,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +305,27 @@ async def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +338,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +360,76 @@ async def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -301,28 +439,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -334,46 +466,55 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _update_initial( self, @@ -381,39 +522,55 @@ async def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -421,18 +578,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +683,27 @@ async def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +716,21 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +738,105 @@ async def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +850,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 @@ -599,8 +861,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_build_service_agent_pool_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_build_service_agent_pool_operations.py index 05fa4b953ae2..be2f2c335cf2 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_build_service_agent_pool_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_build_service_agent_pool_operations.py @@ -6,104 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._build_service_agent_pool_operations import build_get_request, build_list_request, build_update_put_request_initial -T = TypeVar('T') +from ...operations._build_service_agent_pool_operations import ( + build_get_request, + build_list_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildServiceAgentPoolOperations: - """BuildServiceAgentPoolOperations 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 BuildServiceAgentPoolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service_agent_pool` 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, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildServiceAgentPoolResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildServiceAgentPoolResource"]: """List build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceAgentPoolResourceCollection or the - result of cls(response) + :return: An iterator like instance of either BuildServiceAgentPoolResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -117,10 +144,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 @@ -130,78 +155,78 @@ 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - agent_pool_name: str, - **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": + self, resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: """Get build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildServiceAgentPoolResource, or the result of cls(response) + :return: BuildServiceAgentPoolResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore async def _update_put_initial( self, @@ -209,39 +234,55 @@ async def _update_put_initial( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] + ) -> _models.BuildServiceAgentPoolResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(agent_pool_resource, 'BuildServiceAgentPoolResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(agent_pool_resource, (IO, bytes)): + _content = agent_pool_resource + else: + _json = self._serialize.body(agent_pool_resource, "BuildServiceAgentPoolResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -249,18 +290,104 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: _models.BuildServiceAgentPoolResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( @@ -269,23 +396,27 @@ async def begin_update_put( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BuildServiceAgentPoolResource"]: + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: """Create or update build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str - :param agent_pool_resource: Parameters for the update operation. + :param agent_pool_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type agent_pool_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -298,19 +429,21 @@ async def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, @@ -318,29 +451,35 @@ async def begin_update_put( agent_pool_resource=agent_pool_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_build_service_builder_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_build_service_builder_operations.py index e7c8a2a7c5f9..70e1ddb00f2c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_build_service_builder_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_build_service_builder_operations.py @@ -6,113 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._build_service_builder_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._build_service_builder_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildServiceBuilderOperations: - """BuildServiceBuilderOperations 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 BuildServiceBuilderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service_builder` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> "_models.BuilderResource": + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.BuilderResource: """Get a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuilderResource, or the result of cls(response) + :return: BuilderResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +140,55 @@ async def _create_or_update_initial( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> "_models.BuilderResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] + ) -> _models.BuilderResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(builder_resource, 'BuilderResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(builder_resource, (IO, bytes)): + _content = builder_resource + else: + _json = self._serialize.body(builder_resource, "BuilderResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -160,18 +196,103 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: _models.BuilderResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,22 +301,27 @@ async def begin_create_or_update( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BuilderResource"]: + ) -> AsyncLROPoller[_models.BuilderResource]: """Create or update a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param builder_resource: The target builder for the create or update operation. - :type builder_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource + :param builder_resource: The target builder for the create or update operation. Is either a + model type or a IO type. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -208,19 +334,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -228,67 +356,76 @@ async def begin_create_or_update( builder_resource=builder_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, build_service_name: str, builder_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -298,28 +435,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_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. @@ -331,104 +462,122 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuilderResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuilderResource"]: """List KPack builders result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuilderResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BuilderResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -442,10 +591,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 @@ -455,8 +602,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_build_service_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_build_service_operations.py index 8184e9aa40d5..97c9417c3920 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_build_service_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_build_service_operations.py @@ -6,97 +6,135 @@ # Code generated 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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._build_service_operations import build_create_or_update_build_request, build_get_build_request, build_get_build_result_log_request, build_get_build_result_request, build_get_build_service_request, build_get_resource_upload_url_request, build_get_supported_buildpack_request, build_get_supported_stack_request, build_list_build_results_request, build_list_build_services_request, build_list_builds_request, build_list_supported_buildpacks_request, build_list_supported_stacks_request -T = TypeVar('T') +from ...operations._build_service_operations import ( + build_create_or_update_build_request, + build_get_build_request, + build_get_build_result_log_request, + build_get_build_result_request, + build_get_build_service_request, + build_get_resource_upload_url_request, + build_get_supported_buildpack_request, + build_get_supported_stack_request, + build_list_build_results_request, + build_list_build_services_request, + build_list_builds_request, + build_list_supported_buildpacks_request, + build_list_supported_stacks_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildServiceOperations: - """BuildServiceOperations 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 BuildServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service` 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_build_services( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildServiceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildService"]: """List build services resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceCollection or the result of - cls(response) + :return: An iterator like instance of either BuildService or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildService] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_services_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_services.metadata['url'], + template_url=self.list_build_services.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_build_services_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -110,10 +148,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 @@ -123,131 +159,142 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_build_services.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore + list_build_services.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore @distributed_trace_async async def get_build_service( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.BuildService": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.BuildService: """Get a build service resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildService, or the result of cls(response) + :return: BuildService or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildService - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildService"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildService] - request = build_get_build_service_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_service.metadata['url'], + template_url=self.get_build_service.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildService', pipeline_response) + deserialized = self._deserialize("BuildService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore - + get_build_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore @distributed_trace def list_builds( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Build"]: """List KPack builds. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildCollection or the result of cls(response) + :return: An iterator like instance of either Build or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_builds_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_builds.metadata['url'], + template_url=self.list_builds.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_builds_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -261,10 +308,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 @@ -274,78 +319,146 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_builds.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore + list_builds.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore @distributed_trace_async async def get_build( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> "_models.Build": + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> _models.Build: """Get a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - request = build_get_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build.metadata['url'], + template_url=self.get_build.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + get_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + @overload + async def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: _models.Build, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Build + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update_build( @@ -354,57 +467,77 @@ async def create_or_update_build( service_name: str, build_service_name: str, build_name: str, - build: "_models.Build", + build: Union[_models.Build, IO], **kwargs: Any - ) -> "_models.Build": + ) -> _models.Build: """Create or update a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build: Parameters for the create or update operation. - :type build: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Build + :param build: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type build: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Build or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - _json = self._serialize.body(build, 'Build') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build, (IO, bytes)): + _content = build + else: + _json = self._serialize.body(build, "Build") request = build_create_or_update_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_build.metadata['url'], + content=_content, + template_url=self.create_or_update_build.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]: @@ -412,81 +545,87 @@ async def create_or_update_build( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore - + create_or_update_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore @distributed_trace def list_build_results( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildResultCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildResult"]: """List KPack build results. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildResultCollection or the result of - cls(response) + :return: An iterator like instance of either BuildResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildResultCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_results_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_results.metadata['url'], + template_url=self.list_build_results.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_build_results_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - build_name=build_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -500,10 +639,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 @@ -513,11 +650,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_build_results.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore + list_build_results.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore @distributed_trace_async async def get_build_result( @@ -528,67 +663,74 @@ async def get_build_result( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResult": + ) -> _models.BuildResult: """Get a KPack build result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResult, or the result of cls(response) + :return: BuildResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResult] - request = build_get_build_result_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result.metadata['url'], + template_url=self.get_build_result.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResult', pipeline_response) + deserialized = self._deserialize("BuildResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore - + get_build_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore @distributed_trace_async async def get_build_result_log( @@ -599,387 +741,407 @@ async def get_build_result_log( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResultLog": + ) -> _models.BuildResultLog: """Get a KPack build result log download URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResultLog, or the result of cls(response) + :return: BuildResultLog or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildResultLog - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultLog"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultLog] - request = build_get_build_result_log_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result_log.metadata['url'], + template_url=self.get_build_result_log.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResultLog', pipeline_response) + deserialized = self._deserialize("BuildResultLog", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result_log.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore - + get_build_result_log.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore @distributed_trace_async async def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for build service, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore @distributed_trace_async async def list_supported_buildpacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedBuildpacksCollection: """Get all supported buildpacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpacksCollection, or the result of cls(response) + :return: SupportedBuildpacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.SupportedBuildpacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpacksCollection] - request = build_list_supported_buildpacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_buildpacks.metadata['url'], + template_url=self.list_supported_buildpacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedBuildpacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_buildpacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore - + list_supported_buildpacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore @distributed_trace_async async def get_supported_buildpack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - buildpack_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, **kwargs: Any + ) -> _models.SupportedBuildpackResource: """Get the supported buildpack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param buildpack_name: The name of the buildpack resource. + :param buildpack_name: The name of the buildpack resource. Required. :type buildpack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpackResource, or the result of cls(response) + :return: SupportedBuildpackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.SupportedBuildpackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpackResource] - request = build_get_supported_buildpack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, buildpack_name=buildpack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_buildpack.metadata['url'], + template_url=self.get_supported_buildpack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpackResource', pipeline_response) + deserialized = self._deserialize("SupportedBuildpackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_buildpack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore - + get_supported_buildpack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore @distributed_trace_async async def list_supported_stacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedStacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedStacksCollection: """Get all supported stacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStacksCollection, or the result of cls(response) + :return: SupportedStacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.SupportedStacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStacksCollection] - request = build_list_supported_stacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_stacks.metadata['url'], + template_url=self.list_supported_stacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedStacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_stacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore - + list_supported_stacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore @distributed_trace_async async def get_supported_stack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - stack_name: str, - **kwargs: Any - ) -> "_models.SupportedStackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, **kwargs: Any + ) -> _models.SupportedStackResource: """Get the supported stack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param stack_name: The name of the stack resource. + :param stack_name: The name of the stack resource. Required. :type stack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStackResource, or the result of cls(response) + :return: SupportedStackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.SupportedStackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStackResource] - request = build_get_supported_stack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, stack_name=stack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_stack.metadata['url'], + template_url=self.get_supported_stack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStackResource', pipeline_response) + deserialized = self._deserialize("SupportedStackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_stack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore - + get_supported_stack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_buildpack_binding_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_buildpack_binding_operations.py index 36bce4599b06..f5480d2a96f4 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_buildpack_binding_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_buildpack_binding_operations.py @@ -6,46 +6,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._buildpack_binding_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._buildpack_binding_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildpackBindingOperations: - """BuildpackBindingOperations 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 BuildpackBindingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`buildpack_binding` 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( @@ -56,67 +74,74 @@ async def get( builder_name: str, buildpack_binding_name: str, **kwargs: Any - ) -> "_models.BuildpackBindingResource": + ) -> _models.BuildpackBindingResource: """Get a buildpack binding by name. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildpackBindingResource, or the result of cls(response) + :return: BuildpackBindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore async def _create_or_update_initial( self, @@ -125,40 +150,56 @@ async def _create_or_update_initial( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: Union[_models.BuildpackBindingResource, IO], **kwargs: Any - ) -> "_models.BuildpackBindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] + ) -> _models.BuildpackBindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(buildpack_binding, 'BuildpackBindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(buildpack_binding, (IO, bytes)): + _content = buildpack_binding + else: + _json = self._serialize.body(buildpack_binding, "BuildpackBindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -166,20 +207,19 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, @@ -187,25 +227,31 @@ async def begin_create_or_update( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: _models.BuildpackBindingResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.BuildpackBindingResource"]: + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: """Create or update a buildpack binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. :type buildpack_binding: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -218,19 +264,114 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] - 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, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildpackBindingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. Is + either a model type or a IO type. Required. + :type buildpack_binding: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildpackBindingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResource] + :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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -239,32 +380,38 @@ async def begin_create_or_update( buildpack_binding=buildpack_binding, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -275,33 +422,41 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements buildpack_binding_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -311,11 +466,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, service_name: str, @@ -327,15 +481,15 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Operation to delete a Buildpack Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_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. @@ -347,110 +501,127 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildpackBindingResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildpackBindingResource"]: """Handles requests to list all buildpack bindings in a builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildpackBindingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either BuildpackBindingResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, - service_name=service_name, - build_service_name=build_service_name, - builder_name=builder_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -464,10 +635,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 @@ -477,8 +646,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_certificates_operations.py index bf472f849021..812a0b27d511 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_certificates_operations.py @@ -6,147 +6,184 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'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_async async def get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(certificate_resource, 'CertificateResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -154,21 +191,101 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -176,21 +293,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CertificateResource"]: + ) -> AsyncLROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type certificate_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -203,84 +324,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -290,25 +423,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -320,98 +448,118 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -425,10 +573,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 @@ -438,8 +584,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_config_servers_operations.py index ab5eceaefaef..eba712a355cd 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_config_servers_operations.py @@ -6,139 +6,174 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._config_servers_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial, build_validate_request_initial -T = TypeVar('T') +from ...operations._config_servers_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConfigServersOperations: - """ConfigServersOperations 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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,37 +181,115 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,86 +302,110 @@ async def begin_update_put( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -276,37 +413,115 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -319,86 +534,110 @@ async def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_settings, 'ConfigServerSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -406,37 +645,115 @@ async def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerSettings + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -449,47 +766,54 @@ async def begin_validate( or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = await self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_configuration_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_configuration_services_operations.py index 6532d671e0f9..077c5de5e291 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_configuration_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_configuration_services_operations.py @@ -6,147 +6,185 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._configuration_services_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_validate_request_initial -T = TypeVar('T') +from ...operations._configuration_services_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConfigurationServicesOperations: - """ConfigurationServicesOperations 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 ConfigurationServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`configuration_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any - ) -> "_models.ConfigurationServiceResource": + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> _models.ConfigurationServiceResource: """Get the Application Configuration Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigurationServiceResource, or the result of cls(response) + :return: ConfigurationServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] + ) -> _models.ConfigurationServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(configuration_service_resource, 'ConfigurationServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_service_resource, (IO, bytes)): + _content = configuration_service_resource + else: + _json = self._serialize.body(configuration_service_resource, "ConfigurationServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -154,18 +192,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: _models.ConfigurationServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -173,22 +293,26 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigurationServiceResource"]: + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: """Create the default Application Configuration Service or update the existing Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param configuration_service_resource: Parameters for the update operation. + :param configuration_service_resource: Parameters for the update operation. Is either a model + type or a IO type. Required. :type configuration_service_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -201,84 +325,96 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + 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, service_name=service_name, configuration_service_name=configuration_service_name, configuration_service_resource=configuration_service_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, configuration_service_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -288,25 +424,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Disable the default Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -318,98 +449,119 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, configuration_service_name=configuration_service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ConfigurationServiceResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationServiceResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationServiceResourceCollection or the - result of cls(response) + :return: An iterator like instance of either ConfigurationServiceResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -423,10 +575,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 @@ -436,49 +586,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore async def _validate_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] + ) -> _models.ConfigurationServiceSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(settings, 'ConfigurationServiceSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(settings, (IO, bytes)): + _content = settings + else: + _json = self._serialize.body(settings, "ConfigurationServiceSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -486,18 +650,97 @@ async def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: _models.ConfigurationServiceSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_validate( @@ -505,20 +748,25 @@ async def begin_validate( resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigurationServiceSettingsValidateResult"]: + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: """Check if the Application Configuration Service settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param settings: Application Configuration Service settings to be validated. + :param settings: Application Configuration Service settings to be validated. Is either a model + type or a IO type. Required. :type settings: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceSettings + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -531,48 +779,55 @@ async def begin_validate( ConfigurationServiceSettingsValidateResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + 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._validate_initial( + raw_result = await self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, settings=settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_custom_domains_operations.py index adf270af6db6..7491abc5a210 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_custom_domains_operations.py @@ -6,113 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._custom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CustomDomainsOperations: - """CustomDomainsOperations 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 CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +141,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -160,21 +197,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +305,27 @@ async def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +338,21 @@ async def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +360,76 @@ async def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -301,28 +439,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -334,46 +466,55 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _update_initial( self, @@ -381,39 +522,55 @@ async def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -421,18 +578,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +683,27 @@ async def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +716,21 @@ async def begin_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +738,106 @@ async def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +851,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 @@ -599,8 +862,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_deployments_operations.py index 07637f590ba1..08bb3f2fe3db 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_deployments_operations.py @@ -6,113 +6,142 @@ # Code generated 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, List, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._deployments_operations import build_create_or_update_request_initial, build_delete_request_initial, build_generate_heap_dump_request_initial, build_generate_thread_dump_request_initial, build_get_log_file_url_request, build_get_request, build_list_for_cluster_request, build_list_request, build_restart_request_initial, build_start_jfr_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._deployments_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_heap_dump_request, + build_generate_thread_dump_request, + build_get_log_file_url_request, + build_get_request, + build_list_for_cluster_request, + build_list_request, + build_restart_request, + build_start_jfr_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations 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 DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +149,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -160,21 +205,107 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,23 +314,27 @@ async def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -212,19 +347,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -232,67 +369,76 @@ async def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -302,28 +448,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -335,46 +475,55 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _update_initial( self, @@ -382,39 +531,55 @@ async def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -422,18 +587,104 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -442,23 +693,27 @@ async def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -471,19 +726,21 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -491,32 +748,38 @@ async def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -526,60 +789,72 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + ) -> AsyncIterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -593,10 +868,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 @@ -606,69 +879,76 @@ 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -682,10 +962,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 @@ -695,46 +973,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -744,28 +1023,22 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -777,81 +1050,93 @@ async def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -861,28 +1146,22 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -894,81 +1173,93 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore async def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -978,28 +1269,22 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async - async def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1011,98 +1296,110 @@ async def begin_restart( # 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async async def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1111,15 +1408,14 @@ async def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1127,39 +1423,55 @@ async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-st service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_heap_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_heap_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_heap_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_heap_dump_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]: @@ -1169,33 +1481,119 @@ async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - _generate_heap_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + _generate_heap_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + @overload + async def begin_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_heap_dump( # pylint: disable=inconsistent-return-statements + async def begin_generate_heap_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Generate Heap Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1206,19 +1604,21 @@ async def begin_generate_heap_dump( # pylint: disable=inconsistent-return-state 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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._generate_heap_dump_initial( + raw_result = await self._generate_heap_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1226,29 +1626,36 @@ async def begin_generate_heap_dump( # pylint: disable=inconsistent-return-state diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_generate_heap_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + begin_generate_heap_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1256,39 +1663,55 @@ async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return- service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_thread_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_thread_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_thread_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_thread_dump_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]: @@ -1298,33 +1721,119 @@ async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return- if cls: return cls(pipeline_response, None, {}) - _generate_thread_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + _generate_thread_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + @overload + async def begin_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_thread_dump( # pylint: disable=inconsistent-return-statements + async def begin_generate_thread_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Generate Thread Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1335,19 +1844,21 @@ async def begin_generate_thread_dump( # pylint: disable=inconsistent-return-sta 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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._generate_thread_dump_initial( + raw_result = await self._generate_thread_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1355,29 +1866,36 @@ async def begin_generate_thread_dump( # pylint: disable=inconsistent-return-sta diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_generate_thread_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + begin_generate_thread_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements self, @@ -1385,39 +1903,55 @@ async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_start_jfr_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_start_jfr_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._start_jfr_initial.metadata['url'], + content=_content, + template_url=self._start_jfr_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]: @@ -1427,33 +1961,119 @@ async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_jfr_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + _start_jfr_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + + @overload + async def begin_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_start_jfr( # pylint: disable=inconsistent-return-statements + async def begin_start_jfr( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Start JFR. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1464,19 +2084,21 @@ async def begin_start_jfr( # 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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._start_jfr_initial( + raw_result = await self._start_jfr_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1484,26 +2106,33 @@ async def begin_start_jfr( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start_jfr.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + begin_start_jfr.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_gateway_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_gateway_custom_domains_operations.py index bda4b0a1ea00..6cabb088c75c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_gateway_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_gateway_custom_domains_operations.py @@ -6,113 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._gateway_custom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._gateway_custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GatewayCustomDomainsOperations: - """GatewayCustomDomainsOperations 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 GatewayCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateway_custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.GatewayCustomDomainResource": + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any + ) -> _models.GatewayCustomDomainResource: """Get the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayCustomDomainResource, or the result of cls(response) + :return: GatewayCustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +140,55 @@ async def _create_or_update_initial( service_name: str, gateway_name: str, domain_name: str, - gateway_custom_domain_resource: "_models.GatewayCustomDomainResource", + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], **kwargs: Any - ) -> "_models.GatewayCustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] + ) -> _models.GatewayCustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_custom_domain_resource, 'GatewayCustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_custom_domain_resource, (IO, bytes)): + _content = gateway_custom_domain_resource + else: + _json = self._serialize.body(gateway_custom_domain_resource, "GatewayCustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: @@ -160,18 +196,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: _models.GatewayCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,24 +304,27 @@ async def begin_create_or_update( service_name: str, gateway_name: str, domain_name: str, - gateway_custom_domain_resource: "_models.GatewayCustomDomainResource", + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GatewayCustomDomainResource"]: + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: """Create or update the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_name: str :param gateway_custom_domain_resource: The gateway custom domain resource for the create or - update operation. + update operation. Is either a model type or a IO type. Required. :type gateway_custom_domain_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -210,19 +337,21 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + 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, service_name=service_name, gateway_name=gateway_name, @@ -230,67 +359,76 @@ async def begin_create_or_update( gateway_custom_domain_resource=gateway_custom_domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_name: str, domain_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: @@ -300,28 +438,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_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. @@ -333,104 +465,123 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.GatewayCustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayCustomDomainResource"]: """Handle requests to list all Spring Cloud Gateway custom domains. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayCustomDomainResourceCollection or the - result of cls(response) + :return: An iterator like instance of either GatewayCustomDomainResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, gateway_name=gateway_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, - service_name=service_name, - gateway_name=gateway_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -444,10 +595,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 @@ -457,8 +606,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_gateway_route_configs_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_gateway_route_configs_operations.py index e50ce43897d7..d1e91c867808 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_gateway_route_configs_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_gateway_route_configs_operations.py @@ -6,113 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._gateway_route_configs_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._gateway_route_configs_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GatewayRouteConfigsOperations: - """GatewayRouteConfigsOperations 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 GatewayRouteConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateway_route_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_async async def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any - ) -> "_models.GatewayRouteConfigResource": + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any + ) -> _models.GatewayRouteConfigResource: """Get the Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayRouteConfigResource, or the result of cls(response) + :return: GatewayRouteConfigResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +140,55 @@ async def _create_or_update_initial( service_name: str, gateway_name: str, route_config_name: str, - gateway_route_config_resource: "_models.GatewayRouteConfigResource", + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], **kwargs: Any - ) -> "_models.GatewayRouteConfigResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] + ) -> _models.GatewayRouteConfigResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_route_config_resource, 'GatewayRouteConfigResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_route_config_resource, (IO, bytes)): + _content = gateway_route_config_resource + else: + _json = self._serialize.body(gateway_route_config_resource, "GatewayRouteConfigResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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]: @@ -160,18 +196,108 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: _models.GatewayRouteConfigResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayRouteConfigResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayRouteConfigResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,25 +306,28 @@ async def begin_create_or_update( service_name: str, gateway_name: str, route_config_name: str, - gateway_route_config_resource: "_models.GatewayRouteConfigResource", + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GatewayRouteConfigResource"]: + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_name: str :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or - update operation. + update operation. Is either a model type or a IO type. Required. :type gateway_route_config_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +340,21 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + 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, service_name=service_name, gateway_name=gateway_name, @@ -231,67 +362,76 @@ async def begin_create_or_update( gateway_route_config_resource=gateway_route_config_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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]: @@ -301,28 +441,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the Spring Cloud Gateway route config. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_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. @@ -334,104 +468,123 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.GatewayRouteConfigResourceCollection"]: + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayRouteConfigResource"]: """Handle requests to list all Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayRouteConfigResourceCollection or the result - of cls(response) + :return: An iterator like instance of either GatewayRouteConfigResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, gateway_name=gateway_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, - service_name=service_name, - gateway_name=gateway_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -445,10 +598,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 @@ -458,8 +609,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_gateways_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_gateways_operations.py index 6a07fd9f990b..6d7b02c8e91f 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_gateways_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_gateways_operations.py @@ -6,147 +6,185 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._gateways_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_validate_domain_request -T = TypeVar('T') +from ...operations._gateways_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GatewaysOperations: - """GatewaysOperations 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 GatewaysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateways` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> "_models.GatewayResource": + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> _models.GatewayResource: """Get the Spring Cloud Gateway and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayResource, or the result of cls(response) + :return: GatewayResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, gateway_name: str, - gateway_resource: "_models.GatewayResource", + gateway_resource: Union[_models.GatewayResource, IO], **kwargs: Any - ) -> "_models.GatewayResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] + ) -> _models.GatewayResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_resource, 'GatewayResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_resource, (IO, bytes)): + _content = gateway_resource + else: + _json = self._serialize.body(gateway_resource, "GatewayResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: @@ -154,18 +192,97 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: _models.GatewayResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -173,20 +290,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, gateway_name: str, - gateway_resource: "_models.GatewayResource", + gateway_resource: Union[_models.GatewayResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GatewayResource"]: + ) -> AsyncLROPoller[_models.GatewayResource]: """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param gateway_resource: The gateway for the create or update operation. - :type gateway_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource + :param gateway_resource: The gateway for the create or update operation. Is either a model type + or a IO type. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -199,84 +321,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + 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, service_name=service_name, gateway_name=gateway_name, gateway_resource=gateway_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: @@ -286,25 +420,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Disable the default Spring Cloud Gateway. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -316,98 +445,118 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, gateway_name=gateway_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.GatewayResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayResourceCollection or the result of - cls(response) + :return: An iterator like instance of either GatewayResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -421,10 +570,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 @@ -434,79 +581,159 @@ 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.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore - @distributed_trace_async + @overload async def validate_domain( self, resource_group_name: str, service_name: str, gateway_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the domains are valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_monitoring_settings_operations.py index 3598039f413d..d7666aca3f59 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_monitoring_settings_operations.py @@ -6,139 +6,175 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._monitoring_settings_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial -T = TypeVar('T') +from ...operations._monitoring_settings_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MonitoringSettingsOperations: - """MonitoringSettingsOperations 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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,37 +182,115 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,86 +303,110 @@ async def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -276,37 +414,115 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -319,47 +535,55 @@ async def begin_update_patch( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_operations.py index c91fe0675ca1..9e5f3eea1e4e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_operations.py @@ -6,82 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.appplatform.v2022_01_01_preview.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,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 @@ -108,8 +134,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_runtime_versions_operations.py index d2534b0635f0..8abf0688a8a8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_runtime_versions_operations.py @@ -6,88 +6,104 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import 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._runtime_versions_operations import build_list_runtime_versions_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RuntimeVersionsOperations: - """RuntimeVersionsOperations 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 RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + async def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_service_registries_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_service_registries_operations.py index 7345418874bb..4d04bb3adb01 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_service_registries_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_service_registries_operations.py @@ -6,142 +6,167 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._service_registries_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._service_registries_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ServiceRegistriesOperations: - """ServiceRegistriesOperations 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 ServiceRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`service_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: """Get the Service Registry and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceRegistryResource, or the result of cls(response) + :return: ServiceRegistryResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceRegistryResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._create_or_update_initial.metadata['url'], + 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]: @@ -149,35 +174,30 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace_async async def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceRegistryResource"]: + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceRegistryResource]: """Create the default Service Registry or update the existing Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -191,81 +211,93 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceRegistryResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: @@ -275,25 +307,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Disable the default Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -305,98 +332,119 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceRegistryResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServiceRegistryResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceRegistryResourceCollection or the result of + :return: An iterator like instance of either ServiceRegistryResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceRegistryResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceRegistryResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -410,10 +458,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 @@ -423,8 +469,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_services_operations.py index ad5a79c85244..782c3f2f50f8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_services_operations.py @@ -6,141 +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, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._services_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_disable_test_endpoint_request, build_enable_test_endpoint_request, build_get_request, build_list_by_subscription_request, build_list_request, build_list_test_keys_request, build_regenerate_test_key_request, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._services_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_disable_test_endpoint_request, + build_enable_test_endpoint_request, + build_get_request, + build_list_by_subscription_request, + build_list_request, + build_list_test_keys_request, + build_regenerate_test_key_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ServicesOperations: - """ServicesOperations 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 ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -148,39 +189,43 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -193,81 +238,163 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] + :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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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]: @@ -277,22 +404,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -304,80 +425,101 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -385,36 +527,40 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -427,220 +573,380 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] + :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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + async def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2022_01_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace_async async def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -650,98 +956,106 @@ async def disable_test_endpoint( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace_async async def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -751,22 +1065,16 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_stop(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Stop a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -778,75 +1086,89 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -856,22 +1178,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_start(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Start a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -883,147 +1199,230 @@ async def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2022_01_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(availability_parameters, 'NameAvailabilityParameters') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1037,10 +1436,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 @@ -1050,58 +1447,68 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1115,10 +1522,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 @@ -1128,8 +1533,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_skus_operations.py index 2d4863be2990..db754bbc67b8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_skus_operations.py @@ -6,85 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SkusOperations: - """SkusOperations 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 SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) + :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -98,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 @@ -111,8 +135,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_storages_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_storages_operations.py index e0e602f6d275..414ab37c6ec8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_storages_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/aio/operations/_storages_operations.py @@ -6,147 +6,184 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._storages_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._storages_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StoragesOperations: - """StoragesOperations 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 StoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.aio.AppPlatformManagementClient`'s + :attr:`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 get( - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any - ) -> "_models.StorageResource": + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> _models.StorageResource: """Get the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageResource, or the result of cls(response) + :return: StorageResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> "_models.StorageResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] + ) -> _models.StorageResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(storage_resource, 'StorageResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_resource, (IO, bytes)): + _content = storage_resource + else: + _json = self._serialize.body(storage_resource, "StorageResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -154,21 +191,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: _models.StorageResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -176,20 +292,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.StorageResource"]: + ) -> AsyncLROPoller[_models.StorageResource]: """Create or update storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str - :param storage_resource: Parameters for the create or update operation. - :type storage_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource + :param storage_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -202,84 +323,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + 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, service_name=service_name, storage_name=storage_name, storage_resource=storage_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, storage_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, storage_name=storage_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]: @@ -289,25 +422,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_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. @@ -319,98 +447,118 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, storage_name=storage_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.StorageResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageResource"]: """List all the storages of one Azure Spring Cloud instance. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageResourceCollection or the result of - cls(response) + :return: An iterator like instance of either StorageResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -424,10 +572,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 @@ -437,8 +583,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/__init__.py index 70cda27f9acd..5301fce9dc81 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/__init__.py @@ -173,237 +173,239 @@ from ._models_py3 import UserSourceInfo from ._models_py3 import ValidationMessages - -from ._app_platform_management_client_enums import ( - ActionType, - ApiPortalProvisioningState, - AppResourceProvisioningState, - BindingType, - BuildProvisioningState, - BuildResultProvisioningState, - BuildServiceProvisioningState, - BuilderProvisioningState, - BuildpackBindingProvisioningState, - ConfigServerState, - ConfigurationServiceProvisioningState, - CreatedByType, - DeploymentResourceProvisioningState, - DeploymentResourceStatus, - GatewayProvisioningState, - KPackBuildStageProvisioningState, - LastModifiedByType, - ManagedIdentityType, - MonitoringSettingState, - PowerState, - ProvisioningState, - ResourceSkuRestrictionsReasonCode, - ResourceSkuRestrictionsType, - ServiceRegistryProvisioningState, - SkuScaleType, - StorageType, - SupportedRuntimePlatform, - SupportedRuntimeValue, - TestKeyType, - TrafficDirection, - Type, -) +from ._app_platform_management_client_enums import ActionType +from ._app_platform_management_client_enums import ApiPortalProvisioningState +from ._app_platform_management_client_enums import AppResourceProvisioningState +from ._app_platform_management_client_enums import BindingType +from ._app_platform_management_client_enums import BuildProvisioningState +from ._app_platform_management_client_enums import BuildResultProvisioningState +from ._app_platform_management_client_enums import BuildServiceProvisioningState +from ._app_platform_management_client_enums import BuilderProvisioningState +from ._app_platform_management_client_enums import BuildpackBindingProvisioningState +from ._app_platform_management_client_enums import ConfigServerState +from ._app_platform_management_client_enums import ConfigurationServiceProvisioningState +from ._app_platform_management_client_enums import CreatedByType +from ._app_platform_management_client_enums import DeploymentResourceProvisioningState +from ._app_platform_management_client_enums import DeploymentResourceStatus +from ._app_platform_management_client_enums import GatewayProvisioningState +from ._app_platform_management_client_enums import KPackBuildStageProvisioningState +from ._app_platform_management_client_enums import LastModifiedByType +from ._app_platform_management_client_enums import ManagedIdentityType +from ._app_platform_management_client_enums import MonitoringSettingState +from ._app_platform_management_client_enums import PowerState +from ._app_platform_management_client_enums import ProvisioningState +from ._app_platform_management_client_enums import ResourceSkuRestrictionsReasonCode +from ._app_platform_management_client_enums import ResourceSkuRestrictionsType +from ._app_platform_management_client_enums import ServiceRegistryProvisioningState +from ._app_platform_management_client_enums import SkuScaleType +from ._app_platform_management_client_enums import StorageType +from ._app_platform_management_client_enums import SupportedRuntimePlatform +from ._app_platform_management_client_enums import SupportedRuntimeValue +from ._app_platform_management_client_enums import TestKeyType +from ._app_platform_management_client_enums import TrafficDirection +from ._app_platform_management_client_enums import Type +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__ = [ - 'ActiveDeploymentCollection', - 'ApiPortalCustomDomainProperties', - 'ApiPortalCustomDomainResource', - 'ApiPortalCustomDomainResourceCollection', - 'ApiPortalInstance', - 'ApiPortalProperties', - 'ApiPortalResource', - 'ApiPortalResourceCollection', - 'ApiPortalResourceRequests', - 'AppResource', - 'AppResourceCollection', - 'AppResourceProperties', - 'ApplicationInsightsAgentVersions', - 'AvailableOperations', - 'AvailableRuntimeVersions', - 'AzureFileVolume', - 'BindingResource', - 'BindingResourceCollection', - 'BindingResourceProperties', - 'Build', - 'BuildCollection', - 'BuildProperties', - 'BuildResult', - 'BuildResultCollection', - 'BuildResultLog', - 'BuildResultProperties', - 'BuildResultUserSourceInfo', - 'BuildService', - 'BuildServiceAgentPoolProperties', - 'BuildServiceAgentPoolResource', - 'BuildServiceAgentPoolResourceCollection', - 'BuildServiceAgentPoolSizeProperties', - 'BuildServiceCollection', - 'BuildServiceProperties', - 'BuildServicePropertiesResourceRequests', - 'BuildStageProperties', - 'BuilderProperties', - 'BuilderResource', - 'BuilderResourceCollection', - 'BuildpackBindingLaunchProperties', - 'BuildpackBindingProperties', - 'BuildpackBindingResource', - 'BuildpackBindingResourceCollection', - 'BuildpackProperties', - 'BuildpacksGroupProperties', - 'CertificateProperties', - 'CertificateResource', - 'CertificateResourceCollection', - 'CloudErrorBody', - 'ClusterResourceProperties', - 'ConfigServerGitProperty', - 'ConfigServerProperties', - 'ConfigServerResource', - 'ConfigServerSettings', - 'ConfigServerSettingsErrorRecord', - 'ConfigServerSettingsValidateResult', - 'ConfigurationServiceGitProperty', - 'ConfigurationServiceGitPropertyValidateResult', - 'ConfigurationServiceGitRepository', - 'ConfigurationServiceInstance', - 'ConfigurationServiceProperties', - 'ConfigurationServiceResource', - 'ConfigurationServiceResourceCollection', - 'ConfigurationServiceResourceRequests', - 'ConfigurationServiceSettings', - 'ConfigurationServiceSettingsValidateResult', - 'ContainerProbeSettings', - 'ContentCertificateProperties', - 'CustomContainer', - 'CustomContainerUserSourceInfo', - 'CustomDomainProperties', - 'CustomDomainResource', - 'CustomDomainResourceCollection', - 'CustomDomainValidatePayload', - 'CustomDomainValidateResult', - 'CustomPersistentDiskProperties', - 'CustomPersistentDiskResource', - 'DeploymentInstance', - 'DeploymentResource', - 'DeploymentResourceCollection', - 'DeploymentResourceProperties', - 'DeploymentSettings', - 'DiagnosticParameters', - 'Error', - 'GatewayApiMetadataProperties', - 'GatewayApiRoute', - 'GatewayCorsProperties', - 'GatewayCustomDomainProperties', - 'GatewayCustomDomainResource', - 'GatewayCustomDomainResourceCollection', - 'GatewayInstance', - 'GatewayOperatorProperties', - 'GatewayOperatorResourceRequests', - 'GatewayProperties', - 'GatewayResource', - 'GatewayResourceCollection', - 'GatewayResourceRequests', - 'GatewayRouteConfigProperties', - 'GatewayRouteConfigResource', - 'GatewayRouteConfigResourceCollection', - 'GitPatternRepository', - 'ImageRegistryCredential', - 'JarUploadedUserSourceInfo', - 'KeyVaultCertificateProperties', - 'LoadedCertificate', - 'LogFileUrlResponse', - 'LogSpecification', - 'ManagedIdentityProperties', - 'MetricDimension', - 'MetricSpecification', - 'MonitoringSettingProperties', - 'MonitoringSettingResource', - 'NameAvailability', - 'NameAvailabilityParameters', - 'NetCoreZipUploadedUserSourceInfo', - 'NetworkProfile', - 'NetworkProfileOutboundIPs', - 'OperationDetail', - 'OperationDisplay', - 'OperationProperties', - 'PersistentDisk', - 'ProxyResource', - 'RegenerateTestKeyRequestPayload', - 'RequiredTraffic', - 'Resource', - 'ResourceRequests', - 'ResourceSku', - 'ResourceSkuCapabilities', - 'ResourceSkuCollection', - 'ResourceSkuLocationInfo', - 'ResourceSkuRestrictionInfo', - 'ResourceSkuRestrictions', - 'ResourceSkuZoneDetails', - 'ResourceUploadDefinition', - 'ServiceRegistryInstance', - 'ServiceRegistryProperties', - 'ServiceRegistryResource', - 'ServiceRegistryResourceCollection', - 'ServiceRegistryResourceRequests', - 'ServiceResource', - 'ServiceResourceList', - 'ServiceSpecification', - 'Sku', - 'SkuCapacity', - 'SourceUploadedUserSourceInfo', - 'SsoProperties', - 'StackProperties', - 'StorageAccount', - 'StorageProperties', - 'StorageResource', - 'StorageResourceCollection', - 'SupportedBuildpackResource', - 'SupportedBuildpackResourceProperties', - 'SupportedBuildpacksCollection', - 'SupportedRuntimeVersion', - 'SupportedStackResource', - 'SupportedStackResourceProperties', - 'SupportedStacksCollection', - 'SystemData', - 'TemporaryDisk', - 'TestKeys', - 'TrackedResource', - 'TriggeredBuildResult', - 'UploadedUserSourceInfo', - 'UserSourceInfo', - 'ValidationMessages', - 'ActionType', - 'ApiPortalProvisioningState', - 'AppResourceProvisioningState', - 'BindingType', - 'BuildProvisioningState', - 'BuildResultProvisioningState', - 'BuildServiceProvisioningState', - 'BuilderProvisioningState', - 'BuildpackBindingProvisioningState', - 'ConfigServerState', - 'ConfigurationServiceProvisioningState', - 'CreatedByType', - 'DeploymentResourceProvisioningState', - 'DeploymentResourceStatus', - 'GatewayProvisioningState', - 'KPackBuildStageProvisioningState', - 'LastModifiedByType', - 'ManagedIdentityType', - 'MonitoringSettingState', - 'PowerState', - 'ProvisioningState', - 'ResourceSkuRestrictionsReasonCode', - 'ResourceSkuRestrictionsType', - 'ServiceRegistryProvisioningState', - 'SkuScaleType', - 'StorageType', - 'SupportedRuntimePlatform', - 'SupportedRuntimeValue', - 'TestKeyType', - 'TrafficDirection', - 'Type', + "ActiveDeploymentCollection", + "ApiPortalCustomDomainProperties", + "ApiPortalCustomDomainResource", + "ApiPortalCustomDomainResourceCollection", + "ApiPortalInstance", + "ApiPortalProperties", + "ApiPortalResource", + "ApiPortalResourceCollection", + "ApiPortalResourceRequests", + "AppResource", + "AppResourceCollection", + "AppResourceProperties", + "ApplicationInsightsAgentVersions", + "AvailableOperations", + "AvailableRuntimeVersions", + "AzureFileVolume", + "BindingResource", + "BindingResourceCollection", + "BindingResourceProperties", + "Build", + "BuildCollection", + "BuildProperties", + "BuildResult", + "BuildResultCollection", + "BuildResultLog", + "BuildResultProperties", + "BuildResultUserSourceInfo", + "BuildService", + "BuildServiceAgentPoolProperties", + "BuildServiceAgentPoolResource", + "BuildServiceAgentPoolResourceCollection", + "BuildServiceAgentPoolSizeProperties", + "BuildServiceCollection", + "BuildServiceProperties", + "BuildServicePropertiesResourceRequests", + "BuildStageProperties", + "BuilderProperties", + "BuilderResource", + "BuilderResourceCollection", + "BuildpackBindingLaunchProperties", + "BuildpackBindingProperties", + "BuildpackBindingResource", + "BuildpackBindingResourceCollection", + "BuildpackProperties", + "BuildpacksGroupProperties", + "CertificateProperties", + "CertificateResource", + "CertificateResourceCollection", + "CloudErrorBody", + "ClusterResourceProperties", + "ConfigServerGitProperty", + "ConfigServerProperties", + "ConfigServerResource", + "ConfigServerSettings", + "ConfigServerSettingsErrorRecord", + "ConfigServerSettingsValidateResult", + "ConfigurationServiceGitProperty", + "ConfigurationServiceGitPropertyValidateResult", + "ConfigurationServiceGitRepository", + "ConfigurationServiceInstance", + "ConfigurationServiceProperties", + "ConfigurationServiceResource", + "ConfigurationServiceResourceCollection", + "ConfigurationServiceResourceRequests", + "ConfigurationServiceSettings", + "ConfigurationServiceSettingsValidateResult", + "ContainerProbeSettings", + "ContentCertificateProperties", + "CustomContainer", + "CustomContainerUserSourceInfo", + "CustomDomainProperties", + "CustomDomainResource", + "CustomDomainResourceCollection", + "CustomDomainValidatePayload", + "CustomDomainValidateResult", + "CustomPersistentDiskProperties", + "CustomPersistentDiskResource", + "DeploymentInstance", + "DeploymentResource", + "DeploymentResourceCollection", + "DeploymentResourceProperties", + "DeploymentSettings", + "DiagnosticParameters", + "Error", + "GatewayApiMetadataProperties", + "GatewayApiRoute", + "GatewayCorsProperties", + "GatewayCustomDomainProperties", + "GatewayCustomDomainResource", + "GatewayCustomDomainResourceCollection", + "GatewayInstance", + "GatewayOperatorProperties", + "GatewayOperatorResourceRequests", + "GatewayProperties", + "GatewayResource", + "GatewayResourceCollection", + "GatewayResourceRequests", + "GatewayRouteConfigProperties", + "GatewayRouteConfigResource", + "GatewayRouteConfigResourceCollection", + "GitPatternRepository", + "ImageRegistryCredential", + "JarUploadedUserSourceInfo", + "KeyVaultCertificateProperties", + "LoadedCertificate", + "LogFileUrlResponse", + "LogSpecification", + "ManagedIdentityProperties", + "MetricDimension", + "MetricSpecification", + "MonitoringSettingProperties", + "MonitoringSettingResource", + "NameAvailability", + "NameAvailabilityParameters", + "NetCoreZipUploadedUserSourceInfo", + "NetworkProfile", + "NetworkProfileOutboundIPs", + "OperationDetail", + "OperationDisplay", + "OperationProperties", + "PersistentDisk", + "ProxyResource", + "RegenerateTestKeyRequestPayload", + "RequiredTraffic", + "Resource", + "ResourceRequests", + "ResourceSku", + "ResourceSkuCapabilities", + "ResourceSkuCollection", + "ResourceSkuLocationInfo", + "ResourceSkuRestrictionInfo", + "ResourceSkuRestrictions", + "ResourceSkuZoneDetails", + "ResourceUploadDefinition", + "ServiceRegistryInstance", + "ServiceRegistryProperties", + "ServiceRegistryResource", + "ServiceRegistryResourceCollection", + "ServiceRegistryResourceRequests", + "ServiceResource", + "ServiceResourceList", + "ServiceSpecification", + "Sku", + "SkuCapacity", + "SourceUploadedUserSourceInfo", + "SsoProperties", + "StackProperties", + "StorageAccount", + "StorageProperties", + "StorageResource", + "StorageResourceCollection", + "SupportedBuildpackResource", + "SupportedBuildpackResourceProperties", + "SupportedBuildpacksCollection", + "SupportedRuntimeVersion", + "SupportedStackResource", + "SupportedStackResourceProperties", + "SupportedStacksCollection", + "SystemData", + "TemporaryDisk", + "TestKeys", + "TrackedResource", + "TriggeredBuildResult", + "UploadedUserSourceInfo", + "UserSourceInfo", + "ValidationMessages", + "ActionType", + "ApiPortalProvisioningState", + "AppResourceProvisioningState", + "BindingType", + "BuildProvisioningState", + "BuildResultProvisioningState", + "BuildServiceProvisioningState", + "BuilderProvisioningState", + "BuildpackBindingProvisioningState", + "ConfigServerState", + "ConfigurationServiceProvisioningState", + "CreatedByType", + "DeploymentResourceProvisioningState", + "DeploymentResourceStatus", + "GatewayProvisioningState", + "KPackBuildStageProvisioningState", + "LastModifiedByType", + "ManagedIdentityType", + "MonitoringSettingState", + "PowerState", + "ProvisioningState", + "ResourceSkuRestrictionsReasonCode", + "ResourceSkuRestrictionsType", + "ServiceRegistryProvisioningState", + "SkuScaleType", + "StorageType", + "SupportedRuntimePlatform", + "SupportedRuntimeValue", + "TestKeyType", + "TrafficDirection", + "Type", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/_app_platform_management_client_enums.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/_app_platform_management_client_enums.py index b10f39b3966c..835b540defc9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/_app_platform_management_client_enums.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/_app_platform_management_client_enums.py @@ -7,19 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - """ +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" INTERNAL = "Internal" -class ApiPortalProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the API portal. - """ + +class ApiPortalProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the API portal.""" CREATING = "Creating" UPDATING = "Updating" @@ -27,9 +25,9 @@ class ApiPortalProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, En FAILED = "Failed" DELETING = "Deleting" -class AppResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the App - """ + +class AppResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the App.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -37,9 +35,9 @@ class AppResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, UPDATING = "Updating" DELETING = "Deleting" -class BindingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Buildpack Binding Type - """ + +class BindingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Buildpack Binding Type.""" APPLICATION_INSIGHTS = "ApplicationInsights" APACHE_SKY_WALKING = "ApacheSkyWalking" @@ -48,9 +46,9 @@ class BindingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NEW_RELIC = "NewRelic" ELASTIC_APM = "ElasticAPM" -class BuilderProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Builder provision status. - """ + +class BuilderProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Builder provision status.""" CREATING = "Creating" UPDATING = "Updating" @@ -58,9 +56,9 @@ class BuilderProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" DELETING = "Deleting" -class BuildpackBindingProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Buildpack Binding. - """ + +class BuildpackBindingProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Buildpack Binding.""" CREATING = "Creating" UPDATING = "Updating" @@ -68,9 +66,9 @@ class BuildpackBindingProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, FAILED = "Failed" DELETING = "Deleting" -class BuildProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the KPack build result - """ + +class BuildProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" CREATING = "Creating" UPDATING = "Updating" @@ -78,9 +76,9 @@ class BuildProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) FAILED = "Failed" DELETING = "Deleting" -class BuildResultProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the KPack build result - """ + +class BuildResultProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" QUEUING = "Queuing" BUILDING = "Building" @@ -88,9 +86,9 @@ class BuildResultProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, FAILED = "Failed" DELETING = "Deleting" -class BuildServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the KPack build result - """ + +class BuildServiceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" CREATING = "Creating" UPDATING = "Updating" @@ -98,9 +96,9 @@ class BuildServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, FAILED = "Failed" DELETING = "Deleting" -class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the config server. - """ + +class ConfigServerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the config server.""" NOT_AVAILABLE = "NotAvailable" DELETED = "Deleted" @@ -108,9 +106,9 @@ class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ConfigurationServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Application Configuration Service. - """ + +class ConfigurationServiceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Application Configuration Service.""" CREATING = "Creating" UPDATING = "Updating" @@ -118,34 +116,34 @@ class ConfigurationServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMe FAILED = "Failed" DELETING = "Deleting" -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 DeploymentResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Deployment - """ + +class DeploymentResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Deployment.""" CREATING = "Creating" UPDATING = "Updating" SUCCEEDED = "Succeeded" FAILED = "Failed" -class DeploymentResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of the Deployment - """ + +class DeploymentResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the Deployment.""" STOPPED = "Stopped" RUNNING = "Running" -class GatewayProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Spring Cloud Gateway. - """ + +class GatewayProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Spring Cloud Gateway.""" CREATING = "Creating" UPDATING = "Updating" @@ -153,52 +151,52 @@ class GatewayProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" DELETING = "Deleting" -class KPackBuildStageProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of this build stage resource. - """ + +class KPackBuildStageProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of this build stage resource.""" NOT_STARTED = "NotStarted" RUNNING = "Running" SUCCEEDED = "Succeeded" FAILED = "Failed" -class LastModifiedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that last modified the resource. - """ + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class ManagedIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the managed identity - """ + +class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the managed identity.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class MonitoringSettingState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Monitoring Setting. - """ + +class MonitoringSettingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Monitoring Setting.""" NOT_AVAILABLE = "NotAvailable" FAILED = "Failed" SUCCEEDED = "Succeeded" UPDATING = "Updating" -class PowerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Power state of the Service - """ + +class PowerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Power state of the Service.""" RUNNING = "Running" STOPPED = "Stopped" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Service - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Service.""" CREATING = "Creating" UPDATING = "Updating" @@ -212,24 +210,25 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MOVED = "Moved" MOVE_FAILED = "MoveFailed" -class ResourceSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription' + 'NotAvailableForSubscription'. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ResourceSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets the type of restrictions. Possible values include: 'Location', 'Zone' - """ + +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the type of restrictions. Possible values include: 'Location', 'Zone'.""" LOCATION = "Location" ZONE = "Zone" -class ServiceRegistryProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Service Registry. - """ + +class ServiceRegistryProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Service Registry.""" CREATING = "Creating" UPDATING = "Updating" @@ -237,52 +236,52 @@ class ServiceRegistryProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, s FAILED = "Failed" DELETING = "Deleting" -class SkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets or sets the type of the scale. - """ + +class SkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type of the scale.""" NONE = "None" MANUAL = "Manual" AUTOMATIC = "Automatic" -class StorageType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the storage. - """ + +class StorageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the storage.""" STORAGE_ACCOUNT = "StorageAccount" -class SupportedRuntimePlatform(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The platform of this runtime version (possible values: "Java" or ".NET"). - """ + +class SupportedRuntimePlatform(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The platform of this runtime version (possible values: "Java" or ".NET").""" JAVA = "Java" _NET_CORE = ".NET Core" -class SupportedRuntimeValue(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The raw value which could be passed to deployment CRUD operations. - """ + +class SupportedRuntimeValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The raw value which could be passed to deployment CRUD operations.""" JAVA8 = "Java_8" JAVA11 = "Java_11" JAVA17 = "Java_17" NET_CORE31 = "NetCore_31" -class TestKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the test key - """ + +class TestKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the test key.""" PRIMARY = "Primary" SECONDARY = "Secondary" -class TrafficDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The direction of required traffic - """ + +class TrafficDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The direction of required traffic.""" INBOUND = "Inbound" OUTBOUND = "Outbound" -class Type(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the underlying resource to mount as a persistent disk. - """ + +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the underlying resource to mount as a persistent disk.""" AZURE_FILE_VOLUME = "AzureFileVolume" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/_models_py3.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/_models_py3.py index 03e80834738e..364fdbf3806b 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/_models_py3.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,14 +8,23 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._app_platform_management_client_enums import * +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ActiveDeploymentCollection(msrest.serialization.Model): + +class ActiveDeploymentCollection(_serialization.Model): """Object that includes an array of Deployment resource name and set them as active. :ivar active_deployment_names: Collection of Deployment name. @@ -22,24 +32,19 @@ class ActiveDeploymentCollection(msrest.serialization.Model): """ _attribute_map = { - 'active_deployment_names': {'key': 'activeDeploymentNames', 'type': '[str]'}, + "active_deployment_names": {"key": "activeDeploymentNames", "type": "[str]"}, } - def __init__( - self, - *, - active_deployment_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, active_deployment_names: Optional[List[str]] = None, **kwargs): """ :keyword active_deployment_names: Collection of Deployment name. :paramtype active_deployment_names: list[str] """ - super(ActiveDeploymentCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.active_deployment_names = active_deployment_names -class ApiPortalCustomDomainProperties(msrest.serialization.Model): +class ApiPortalCustomDomainProperties(_serialization.Model): """The properties of custom domain for API portal. :ivar thumbprint: The thumbprint of bound certificate. @@ -47,24 +52,19 @@ class ApiPortalCustomDomainProperties(msrest.serialization.Model): """ _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, + "thumbprint": {"key": "thumbprint", "type": "str"}, } - def __init__( - self, - *, - thumbprint: Optional[str] = None, - **kwargs - ): + def __init__(self, *, thumbprint: Optional[str] = None, **kwargs): """ :keyword thumbprint: The thumbprint of bound certificate. :paramtype thumbprint: str """ - super(ApiPortalCustomDomainProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = thumbprint -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The core properties of ARM resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -80,26 +80,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 @@ -122,26 +118,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 ApiPortalCustomDomainResource(ProxyResource): @@ -163,36 +155,31 @@ class ApiPortalCustomDomainResource(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': 'ApiPortalCustomDomainProperties'}, + "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": "ApiPortalCustomDomainProperties"}, } - def __init__( - self, - *, - properties: Optional["ApiPortalCustomDomainProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ApiPortalCustomDomainProperties"] = None, **kwargs): """ :keyword properties: The properties of custom domain for API portal. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainProperties """ - super(ApiPortalCustomDomainResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ApiPortalCustomDomainResourceCollection(msrest.serialization.Model): +class ApiPortalCustomDomainResourceCollection(_serialization.Model): """Object that includes an array of API portal custom domain resources and a possible link for next set. :ivar value: Collection of API portal custom domain resources. @@ -204,14 +191,14 @@ class ApiPortalCustomDomainResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiPortalCustomDomainResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ApiPortalCustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ApiPortalCustomDomainResource"]] = None, + value: Optional[List["_models.ApiPortalCustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -223,12 +210,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ApiPortalCustomDomainResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ApiPortalInstance(msrest.serialization.Model): +class ApiPortalInstance(_serialization.Model): """Collection of instances belong to the API portal. Variables are only populated by the server, and will be ignored when sending a request. @@ -240,33 +227,29 @@ class ApiPortalInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiPortalInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class ApiPortalProperties(msrest.serialization.Model): +class ApiPortalProperties(_serialization.Model): """API portal properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the API portal. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the API portal. Known values are: "Creating", "Updating", + "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalProvisioningState :ivar public: Indicates whether the API portal exposes endpoint. @@ -289,32 +272,32 @@ class ApiPortalProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'url': {'readonly': True}, - 'resource_requests': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "url": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'public': {'key': 'public', 'type': 'bool'}, - 'url': {'key': 'url', 'type': 'str'}, - 'https_only': {'key': 'httpsOnly', 'type': 'bool'}, - 'gateway_ids': {'key': 'gatewayIds', 'type': '[str]'}, - 'source_urls': {'key': 'sourceUrls', 'type': '[str]'}, - 'sso_properties': {'key': 'ssoProperties', 'type': 'SsoProperties'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'ApiPortalResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[ApiPortalInstance]'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "gateway_ids": {"key": "gatewayIds", "type": "[str]"}, + "source_urls": {"key": "sourceUrls", "type": "[str]"}, + "sso_properties": {"key": "ssoProperties", "type": "SsoProperties"}, + "resource_requests": {"key": "resourceRequests", "type": "ApiPortalResourceRequests"}, + "instances": {"key": "instances", "type": "[ApiPortalInstance]"}, } def __init__( self, *, - public: Optional[bool] = False, - https_only: Optional[bool] = False, + public: bool = False, + https_only: bool = False, gateway_ids: Optional[List[str]] = None, source_urls: Optional[List[str]] = None, - sso_properties: Optional["SsoProperties"] = None, + sso_properties: Optional["_models.SsoProperties"] = None, **kwargs ): """ @@ -329,7 +312,7 @@ def __init__( :keyword sso_properties: Single sign-on related configuration. :paramtype sso_properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.SsoProperties """ - super(ApiPortalProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.public = public self.url = None @@ -361,26 +344,26 @@ class ApiPortalResource(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': 'ApiPortalProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "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": "ApiPortalProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( self, *, - properties: Optional["ApiPortalProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.ApiPortalProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -389,12 +372,12 @@ def __init__( :keyword sku: Sku of the API portal resource. :paramtype sku: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Sku """ - super(ApiPortalResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.sku = sku -class ApiPortalResourceCollection(msrest.serialization.Model): +class ApiPortalResourceCollection(_serialization.Model): """Object that includes an array of API portal resources and a possible link for next set. :ivar value: Collection of API portal resources. @@ -405,16 +388,12 @@ class ApiPortalResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiPortalResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ApiPortalResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ApiPortalResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ApiPortalResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of API portal resources. @@ -423,12 +402,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ApiPortalResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ApiPortalResourceRequests(msrest.serialization.Model): +class ApiPortalResourceRequests(_serialization.Model): """Resource requests of the API portal. Variables are only populated by the server, and will be ignored when sending a request. @@ -440,27 +419,23 @@ class ApiPortalResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiPortalResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None -class ApplicationInsightsAgentVersions(msrest.serialization.Model): +class ApplicationInsightsAgentVersions(_serialization.Model): """Application Insights agent versions properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -470,20 +445,16 @@ class ApplicationInsightsAgentVersions(msrest.serialization.Model): """ _validation = { - 'java': {'readonly': True}, + "java": {"readonly": True}, } _attribute_map = { - 'java': {'key': 'java', 'type': 'str'}, + "java": {"key": "java", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApplicationInsightsAgentVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.java = None @@ -509,27 +480,27 @@ class AppResource(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': 'AppResourceProperties'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentityProperties'}, - 'location': {'key': 'location', 'type': 'str'}, + "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": "AppResourceProperties"}, + "identity": {"key": "identity", "type": "ManagedIdentityProperties"}, + "location": {"key": "location", "type": "str"}, } def __init__( self, *, - properties: Optional["AppResourceProperties"] = None, - identity: Optional["ManagedIdentityProperties"] = None, + properties: Optional["_models.AppResourceProperties"] = None, + identity: Optional["_models.ManagedIdentityProperties"] = None, location: Optional[str] = None, **kwargs ): @@ -543,13 +514,13 @@ def __init__( resource. :paramtype location: str """ - super(AppResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.identity = identity self.location = location -class AppResourceCollection(msrest.serialization.Model): +class AppResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of App resources. @@ -560,16 +531,12 @@ class AppResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AppResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AppResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["AppResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.AppResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of App resources. @@ -578,12 +545,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(AppResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class AppResourceProperties(msrest.serialization.Model): +class AppResourceProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """App resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -593,9 +560,9 @@ class AppResourceProperties(msrest.serialization.Model): :ivar url: URL of the App. :vartype url: str :ivar addon_configs: Collection of addons. - :vartype addon_configs: dict[str, dict[str, any]] - :ivar provisioning_state: Provisioning state of the App. Possible values include: "Succeeded", - "Failed", "Creating", "Updating", "Deleting". + :vartype addon_configs: dict[str, dict[str, JSON]] + :ivar provisioning_state: Provisioning state of the App. Known values are: "Succeeded", + "Failed", "Creating", "Updating", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResourceProvisioningState :ivar fqdn: Fully qualified dns Name. @@ -617,43 +584,43 @@ class AppResourceProperties(msrest.serialization.Model): """ _validation = { - 'url': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "url": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'public': {'key': 'public', 'type': 'bool'}, - 'url': {'key': 'url', 'type': 'str'}, - 'addon_configs': {'key': 'addonConfigs', 'type': '{{object}}'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'fqdn': {'key': 'fqdn', 'type': 'str'}, - 'https_only': {'key': 'httpsOnly', 'type': 'bool'}, - 'temporary_disk': {'key': 'temporaryDisk', 'type': 'TemporaryDisk'}, - 'persistent_disk': {'key': 'persistentDisk', 'type': 'PersistentDisk'}, - 'custom_persistent_disks': {'key': 'customPersistentDisks', 'type': '[CustomPersistentDiskResource]'}, - 'enable_end_to_end_tls': {'key': 'enableEndToEndTLS', 'type': 'bool'}, - 'loaded_certificates': {'key': 'loadedCertificates', 'type': '[LoadedCertificate]'}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "addon_configs": {"key": "addonConfigs", "type": "{{object}}"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "fqdn": {"key": "fqdn", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "temporary_disk": {"key": "temporaryDisk", "type": "TemporaryDisk"}, + "persistent_disk": {"key": "persistentDisk", "type": "PersistentDisk"}, + "custom_persistent_disks": {"key": "customPersistentDisks", "type": "[CustomPersistentDiskResource]"}, + "enable_end_to_end_tls": {"key": "enableEndToEndTLS", "type": "bool"}, + "loaded_certificates": {"key": "loadedCertificates", "type": "[LoadedCertificate]"}, } def __init__( self, *, public: Optional[bool] = None, - addon_configs: Optional[Dict[str, Dict[str, Any]]] = None, + addon_configs: Optional[Dict[str, Dict[str, JSON]]] = None, fqdn: Optional[str] = None, - https_only: Optional[bool] = False, - temporary_disk: Optional["TemporaryDisk"] = None, - persistent_disk: Optional["PersistentDisk"] = None, - custom_persistent_disks: Optional[List["CustomPersistentDiskResource"]] = None, - enable_end_to_end_tls: Optional[bool] = False, - loaded_certificates: Optional[List["LoadedCertificate"]] = None, + https_only: bool = False, + temporary_disk: Optional["_models.TemporaryDisk"] = None, + persistent_disk: Optional["_models.PersistentDisk"] = None, + custom_persistent_disks: Optional[List["_models.CustomPersistentDiskResource"]] = None, + enable_end_to_end_tls: bool = False, + loaded_certificates: Optional[List["_models.LoadedCertificate"]] = None, **kwargs ): """ :keyword public: Indicates whether the App exposes public endpoint. :paramtype public: bool :keyword addon_configs: Collection of addons. - :paramtype addon_configs: dict[str, dict[str, any]] + :paramtype addon_configs: dict[str, dict[str, JSON]] :keyword fqdn: Fully qualified dns Name. :paramtype fqdn: str :keyword https_only: Indicate if only https is allowed. @@ -671,7 +638,7 @@ def __init__( :paramtype loaded_certificates: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.LoadedCertificate] """ - super(AppResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.public = public self.url = None self.addon_configs = addon_configs @@ -685,7 +652,7 @@ def __init__( self.loaded_certificates = loaded_certificates -class AvailableOperations(msrest.serialization.Model): +class AvailableOperations(_serialization.Model): """Available operations of the service. :ivar value: Collection of available operation details. @@ -696,16 +663,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. @@ -714,12 +677,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 AvailableRuntimeVersions(msrest.serialization.Model): +class AvailableRuntimeVersions(_serialization.Model): """AvailableRuntimeVersions. Variables are only populated by the server, and will be ignored when sending a request. @@ -730,35 +693,31 @@ class AvailableRuntimeVersions(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedRuntimeVersion]'}, + "value": {"key": "value", "type": "[SupportedRuntimeVersion]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AvailableRuntimeVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class CustomPersistentDiskProperties(msrest.serialization.Model): +class CustomPersistentDiskProperties(_serialization.Model): """Custom persistent disk resource payload. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureFileVolume. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureFileVolume All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the underlying resource to mount as a persistent - disk.Constant filled by server. Possible values include: "AzureFileVolume". + :ivar type: The type of the underlying resource to mount as a persistent disk. Required. + "AzureFileVolume" :vartype type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.Type - :ivar mount_path: Required. The mount path of the persistent disk. + :ivar mount_path: The mount path of the persistent disk. Required. :vartype mount_path: str :ivar read_only: Indicates whether the persistent disk is a readOnly one. :vartype read_only: bool @@ -767,38 +726,31 @@ class CustomPersistentDiskProperties(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, - 'mount_path': {'required': True}, + "type": {"required": True}, + "mount_path": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, - 'read_only': {'key': 'readOnly', 'type': 'bool'}, - 'mount_options': {'key': 'mountOptions', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "mount_path": {"key": "mountPath", "type": "str"}, + "read_only": {"key": "readOnly", "type": "bool"}, + "mount_options": {"key": "mountOptions", "type": "[str]"}, } - _subtype_map = { - 'type': {'AzureFileVolume': 'AzureFileVolume'} - } + _subtype_map = {"type": {"AzureFileVolume": "AzureFileVolume"}} def __init__( - self, - *, - mount_path: str, - read_only: Optional[bool] = None, - mount_options: Optional[List[str]] = None, - **kwargs + self, *, mount_path: str, read_only: Optional[bool] = None, mount_options: Optional[List[str]] = None, **kwargs ): """ - :keyword mount_path: Required. The mount path of the persistent disk. + :keyword mount_path: The mount path of the persistent disk. Required. :paramtype mount_path: str :keyword read_only: Indicates whether the persistent disk is a readOnly one. :paramtype read_only: bool :keyword mount_options: These are the mount options for a persistent disk. :paramtype mount_options: list[str] """ - super(CustomPersistentDiskProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None # type: Optional[str] self.mount_path = mount_path self.read_only = read_only @@ -810,31 +762,31 @@ class AzureFileVolume(CustomPersistentDiskProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the underlying resource to mount as a persistent - disk.Constant filled by server. Possible values include: "AzureFileVolume". + :ivar type: The type of the underlying resource to mount as a persistent disk. Required. + "AzureFileVolume" :vartype type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.Type - :ivar mount_path: Required. The mount path of the persistent disk. + :ivar mount_path: The mount path of the persistent disk. Required. :vartype mount_path: str :ivar read_only: Indicates whether the persistent disk is a readOnly one. :vartype read_only: bool :ivar mount_options: These are the mount options for a persistent disk. :vartype mount_options: list[str] - :ivar share_name: Required. The share name of the Azure File share. + :ivar share_name: The share name of the Azure File share. Required. :vartype share_name: str """ _validation = { - 'type': {'required': True}, - 'mount_path': {'required': True}, - 'share_name': {'required': True}, + "type": {"required": True}, + "mount_path": {"required": True}, + "share_name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, - 'read_only': {'key': 'readOnly', 'type': 'bool'}, - 'mount_options': {'key': 'mountOptions', 'type': '[str]'}, - 'share_name': {'key': 'shareName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "mount_path": {"key": "mountPath", "type": "str"}, + "read_only": {"key": "readOnly", "type": "bool"}, + "mount_options": {"key": "mountOptions", "type": "[str]"}, + "share_name": {"key": "shareName", "type": "str"}, } def __init__( @@ -847,17 +799,17 @@ def __init__( **kwargs ): """ - :keyword mount_path: Required. The mount path of the persistent disk. + :keyword mount_path: The mount path of the persistent disk. Required. :paramtype mount_path: str :keyword read_only: Indicates whether the persistent disk is a readOnly one. :paramtype read_only: bool :keyword mount_options: These are the mount options for a persistent disk. :paramtype mount_options: list[str] - :keyword share_name: Required. The share name of the Azure File share. + :keyword share_name: The share name of the Azure File share. Required. :paramtype share_name: str """ - super(AzureFileVolume, self).__init__(mount_path=mount_path, read_only=read_only, mount_options=mount_options, **kwargs) - self.type = 'AzureFileVolume' # type: str + super().__init__(mount_path=mount_path, read_only=read_only, mount_options=mount_options, **kwargs) + self.type = "AzureFileVolume" # type: str self.share_name = share_name @@ -880,36 +832,31 @@ class BindingResource(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': 'BindingResourceProperties'}, + "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": "BindingResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["BindingResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BindingResourceProperties"] = None, **kwargs): """ :keyword properties: Properties of the Binding resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResourceProperties """ - super(BindingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BindingResourceCollection(msrest.serialization.Model): +class BindingResourceCollection(_serialization.Model): """Object that includes an array of Binding resources and a possible link for next set. :ivar value: Collection of Binding resources. @@ -920,16 +867,12 @@ class BindingResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BindingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BindingResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BindingResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Binding resources. @@ -938,12 +881,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BindingResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BindingResourceProperties(msrest.serialization.Model): +class BindingResourceProperties(_serialization.Model): """Binding resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -957,7 +900,7 @@ class BindingResourceProperties(msrest.serialization.Model): :ivar key: The key of the bound resource. :vartype key: str :ivar binding_parameters: Binding parameters of the Binding resource. - :vartype binding_parameters: dict[str, any] + :vartype binding_parameters: dict[str, JSON] :ivar generated_properties: The generated Spring Boot property file for this binding. The secret will be deducted. :vartype generated_properties: str @@ -968,22 +911,22 @@ class BindingResourceProperties(msrest.serialization.Model): """ _validation = { - 'resource_name': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'generated_properties': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, + "resource_name": {"readonly": True}, + "resource_type": {"readonly": True}, + "generated_properties": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, } _attribute_map = { - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'binding_parameters': {'key': 'bindingParameters', 'type': '{object}'}, - 'generated_properties': {'key': 'generatedProperties', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'str'}, - 'updated_at': {'key': 'updatedAt', 'type': 'str'}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "binding_parameters": {"key": "bindingParameters", "type": "{object}"}, + "generated_properties": {"key": "generatedProperties", "type": "str"}, + "created_at": {"key": "createdAt", "type": "str"}, + "updated_at": {"key": "updatedAt", "type": "str"}, } def __init__( @@ -991,7 +934,7 @@ def __init__( *, resource_id: Optional[str] = None, key: Optional[str] = None, - binding_parameters: Optional[Dict[str, Any]] = None, + binding_parameters: Optional[Dict[str, JSON]] = None, **kwargs ): """ @@ -1000,9 +943,9 @@ def __init__( :keyword key: The key of the bound resource. :paramtype key: str :keyword binding_parameters: Binding parameters of the Binding resource. - :paramtype binding_parameters: dict[str, any] + :paramtype binding_parameters: dict[str, JSON] """ - super(BindingResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_name = None self.resource_type = None self.resource_id = resource_id @@ -1031,35 +974,30 @@ class Build(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': 'BuildProperties'}, + "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": "BuildProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildProperties"] = None, **kwargs): """ :keyword properties: Properties of the build resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildProperties """ - super(Build, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildCollection(msrest.serialization.Model): +class BuildCollection(_serialization.Model): """Object that includes an array of Build resources and a possible link for next set. :ivar value: Collection of Build resources. @@ -1070,17 +1008,11 @@ class BuildCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Build]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Build]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Build"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Build"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Collection of Build resources. :paramtype value: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.Build] @@ -1088,18 +1020,18 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuilderProperties(msrest.serialization.Model): +class BuilderProperties(_serialization.Model): """KPack Builder properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Builder provision status. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Builder provision status. Known values are: "Creating", "Updating", + "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderProvisioningState :ivar stack: Builder cluster stack property. @@ -1110,20 +1042,20 @@ class BuilderProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'stack': {'key': 'stack', 'type': 'StackProperties'}, - 'buildpack_groups': {'key': 'buildpackGroups', 'type': '[BuildpacksGroupProperties]'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "stack": {"key": "stack", "type": "StackProperties"}, + "buildpack_groups": {"key": "buildpackGroups", "type": "[BuildpacksGroupProperties]"}, } def __init__( self, *, - stack: Optional["StackProperties"] = None, - buildpack_groups: Optional[List["BuildpacksGroupProperties"]] = None, + stack: Optional["_models.StackProperties"] = None, + buildpack_groups: Optional[List["_models.BuildpacksGroupProperties"]] = None, **kwargs ): """ @@ -1133,7 +1065,7 @@ def __init__( :paramtype buildpack_groups: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpacksGroupProperties] """ - super(BuilderProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.stack = stack self.buildpack_groups = buildpack_groups @@ -1157,35 +1089,30 @@ class BuilderResource(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': 'BuilderProperties'}, + "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": "BuilderProperties"}, } - def __init__( - self, - *, - properties: Optional["BuilderProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuilderProperties"] = None, **kwargs): """ :keyword properties: Property of the Builder resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderProperties """ - super(BuilderResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuilderResourceCollection(msrest.serialization.Model): +class BuilderResourceCollection(_serialization.Model): """Object that includes an array of Builder resources and a possible link for next set. :ivar value: Collection of Builder resources. @@ -1196,16 +1123,12 @@ class BuilderResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuilderResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuilderResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BuilderResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BuilderResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Builder resources. @@ -1214,12 +1137,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuilderResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildpackBindingLaunchProperties(msrest.serialization.Model): +class BuildpackBindingLaunchProperties(_serialization.Model): """Buildpack Binding Launch Properties. :ivar properties: Non-sensitive properties for launchProperties. @@ -1229,16 +1152,12 @@ class BuildpackBindingLaunchProperties(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'secrets': {'key': 'secrets', 'type': '{str}'}, + "properties": {"key": "properties", "type": "{str}"}, + "secrets": {"key": "secrets", "type": "{str}"}, } def __init__( - self, - *, - properties: Optional[Dict[str, str]] = None, - secrets: Optional[Dict[str, str]] = None, - **kwargs + self, *, properties: Optional[Dict[str, str]] = None, secrets: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword properties: Non-sensitive properties for launchProperties. @@ -1246,21 +1165,21 @@ def __init__( :keyword secrets: Sensitive properties for launchProperties. :paramtype secrets: dict[str, str] """ - super(BuildpackBindingLaunchProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.secrets = secrets -class BuildpackBindingProperties(msrest.serialization.Model): +class BuildpackBindingProperties(_serialization.Model): """Properties of a buildpack binding. Variables are only populated by the server, and will be ignored when sending a request. - :ivar binding_type: Buildpack Binding Type. Possible values include: "ApplicationInsights", - "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", "ElasticAPM". + :ivar binding_type: Buildpack Binding Type. Known values are: "ApplicationInsights", + "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", and "ElasticAPM". :vartype binding_type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingType - :ivar provisioning_state: State of the Buildpack Binding. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Buildpack Binding. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingProvisioningState :ivar launch_properties: The object describes the buildpack binding launch properties. @@ -1269,31 +1188,31 @@ class BuildpackBindingProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'binding_type': {'key': 'bindingType', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'launch_properties': {'key': 'launchProperties', 'type': 'BuildpackBindingLaunchProperties'}, + "binding_type": {"key": "bindingType", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "launch_properties": {"key": "launchProperties", "type": "BuildpackBindingLaunchProperties"}, } def __init__( self, *, - binding_type: Optional[Union[str, "BindingType"]] = None, - launch_properties: Optional["BuildpackBindingLaunchProperties"] = None, + binding_type: Optional[Union[str, "_models.BindingType"]] = None, + launch_properties: Optional["_models.BuildpackBindingLaunchProperties"] = None, **kwargs ): """ - :keyword binding_type: Buildpack Binding Type. Possible values include: "ApplicationInsights", - "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", "ElasticAPM". + :keyword binding_type: Buildpack Binding Type. Known values are: "ApplicationInsights", + "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", and "ElasticAPM". :paramtype binding_type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingType :keyword launch_properties: The object describes the buildpack binding launch properties. :paramtype launch_properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingLaunchProperties """ - super(BuildpackBindingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.binding_type = binding_type self.provisioning_state = None self.launch_properties = launch_properties @@ -1318,36 +1237,31 @@ class BuildpackBindingResource(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': 'BuildpackBindingProperties'}, + "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": "BuildpackBindingProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildpackBindingProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildpackBindingProperties"] = None, **kwargs): """ :keyword properties: Properties of a buildpack binding. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingProperties """ - super(BuildpackBindingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildpackBindingResourceCollection(msrest.serialization.Model): +class BuildpackBindingResourceCollection(_serialization.Model): """Object that includes an array of BuildpackBinding resources and a possible link for next set. :ivar value: Collection of BuildpackBinding resources. @@ -1359,14 +1273,14 @@ class BuildpackBindingResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildpackBindingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildpackBindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["BuildpackBindingResource"]] = None, + value: Optional[List["_models.BuildpackBindingResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1378,12 +1292,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildpackBindingResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildpackProperties(msrest.serialization.Model): +class BuildpackProperties(_serialization.Model): """Buildpack properties payload. :ivar id: Id of the buildpack. @@ -1391,24 +1305,19 @@ class BuildpackProperties(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Id of the buildpack. :paramtype id: str """ - super(BuildpackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class BuildpacksGroupProperties(msrest.serialization.Model): +class BuildpacksGroupProperties(_serialization.Model): """Buildpack group properties of the Builder. :ivar name: Buildpack group name. @@ -1419,16 +1328,12 @@ class BuildpacksGroupProperties(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'buildpacks': {'key': 'buildpacks', 'type': '[BuildpackProperties]'}, + "name": {"key": "name", "type": "str"}, + "buildpacks": {"key": "buildpacks", "type": "[BuildpackProperties]"}, } def __init__( - self, - *, - name: Optional[str] = None, - buildpacks: Optional[List["BuildpackProperties"]] = None, - **kwargs + self, *, name: Optional[str] = None, buildpacks: Optional[List["_models.BuildpackProperties"]] = None, **kwargs ): """ :keyword name: Buildpack group name. @@ -1437,12 +1342,12 @@ def __init__( :paramtype buildpacks: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackProperties] """ - super(BuildpacksGroupProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.buildpacks = buildpacks -class BuildProperties(msrest.serialization.Model): +class BuildProperties(_serialization.Model): """Build resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1453,8 +1358,8 @@ class BuildProperties(msrest.serialization.Model): :vartype builder: str :ivar agent_pool: The resource id of agent pool. :vartype agent_pool: str - :ivar provisioning_state: Provisioning state of the KPack build result. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildProvisioningState :ivar env: The environment variables for this build. @@ -1465,17 +1370,17 @@ class BuildProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'triggered_build_result': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "triggered_build_result": {"readonly": True}, } _attribute_map = { - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'builder': {'key': 'builder', 'type': 'str'}, - 'agent_pool': {'key': 'agentPool', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'env': {'key': 'env', 'type': '{str}'}, - 'triggered_build_result': {'key': 'triggeredBuildResult', 'type': 'TriggeredBuildResult'}, + "relative_path": {"key": "relativePath", "type": "str"}, + "builder": {"key": "builder", "type": "str"}, + "agent_pool": {"key": "agentPool", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "env": {"key": "env", "type": "{str}"}, + "triggered_build_result": {"key": "triggeredBuildResult", "type": "TriggeredBuildResult"}, } def __init__( @@ -1497,7 +1402,7 @@ def __init__( :keyword env: The environment variables for this build. :paramtype env: dict[str, str] """ - super(BuildProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.relative_path = relative_path self.builder = builder self.agent_pool = agent_pool @@ -1524,35 +1429,30 @@ class BuildResult(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': 'BuildResultProperties'}, + "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": "BuildResultProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildResultProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildResultProperties"] = None, **kwargs): """ :keyword properties: Properties of the build result resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildResultProperties """ - super(BuildResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildResultCollection(msrest.serialization.Model): +class BuildResultCollection(_serialization.Model): """Object that includes an array of Build result resources and a possible link for next set. :ivar value: Collection of Build result resources. @@ -1563,16 +1463,12 @@ class BuildResultCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildResult]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BuildResult"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BuildResult"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Build result resources. @@ -1581,12 +1477,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildResultCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildResultLog(msrest.serialization.Model): +class BuildResultLog(_serialization.Model): """Build result log resource properties payload. :ivar blob_url: The public download URL of this build result log. @@ -1594,32 +1490,27 @@ class BuildResultLog(msrest.serialization.Model): """ _attribute_map = { - 'blob_url': {'key': 'blobUrl', 'type': 'str'}, + "blob_url": {"key": "blobUrl", "type": "str"}, } - def __init__( - self, - *, - blob_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, blob_url: Optional[str] = None, **kwargs): """ :keyword blob_url: The public download URL of this build result log. :paramtype blob_url: str """ - super(BuildResultLog, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob_url = blob_url -class BuildResultProperties(msrest.serialization.Model): +class BuildResultProperties(_serialization.Model): """Build result resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. :ivar name: The name of this build result. :vartype name: str - :ivar provisioning_state: Provisioning state of the KPack build result. Possible values - include: "Queuing", "Building", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Queuing", "Building", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildResultProvisioningState :ivar build_pod_name: The build pod name which can be used to get the build log streaming. @@ -1631,75 +1522,68 @@ class BuildResultProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'build_stages': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "build_stages": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'build_pod_name': {'key': 'buildPodName', 'type': 'str'}, - 'build_stages': {'key': 'buildStages', 'type': '[BuildStageProperties]'}, + "name": {"key": "name", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "build_pod_name": {"key": "buildPodName", "type": "str"}, + "build_stages": {"key": "buildStages", "type": "[BuildStageProperties]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - build_pod_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, build_pod_name: Optional[str] = None, **kwargs): """ :keyword name: The name of this build result. :paramtype name: str :keyword build_pod_name: The build pod name which can be used to get the build log streaming. :paramtype build_pod_name: str """ - super(BuildResultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.provisioning_state = None self.build_pod_name = build_pod_name self.build_stages = None -class UserSourceInfo(msrest.serialization.Model): +class UserSourceInfo(_serialization.Model): """Source information for a deployment. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: BuildResultUserSourceInfo, CustomContainerUserSourceInfo, UploadedUserSourceInfo. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + BuildResultUserSourceInfo, CustomContainerUserSourceInfo, UploadedUserSourceInfo All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, } _subtype_map = { - 'type': {'BuildResult': 'BuildResultUserSourceInfo', 'Container': 'CustomContainerUserSourceInfo', 'UploadedUserSourceInfo': 'UploadedUserSourceInfo'} + "type": { + "BuildResult": "BuildResultUserSourceInfo", + "Container": "CustomContainerUserSourceInfo", + "UploadedUserSourceInfo": "UploadedUserSourceInfo", + } } - def __init__( - self, - *, - version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, version: Optional[str] = None, **kwargs): """ :keyword version: Version of the source. :paramtype version: str """ - super(UserSourceInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None # type: Optional[str] self.version = version @@ -1709,7 +1593,7 @@ class BuildResultUserSourceInfo(UserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -1719,22 +1603,16 @@ class BuildResultUserSourceInfo(UserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'build_result_id': {'key': 'buildResultId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "build_result_id": {"key": "buildResultId", "type": "str"}, } - def __init__( - self, - *, - version: Optional[str] = None, - build_result_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, version: Optional[str] = None, build_result_id: Optional[str] = None, **kwargs): """ :keyword version: Version of the source. :paramtype version: str @@ -1742,8 +1620,8 @@ def __init__( Spring instance. :paramtype build_result_id: str """ - super(BuildResultUserSourceInfo, self).__init__(version=version, **kwargs) - self.type = 'BuildResult' # type: str + super().__init__(version=version, **kwargs) + self.type = "BuildResult" # type: str self.build_result_id = build_result_id @@ -1765,36 +1643,31 @@ class BuildService(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': 'BuildServiceProperties'}, + "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": "BuildServiceProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildServiceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildServiceProperties"] = None, **kwargs): """ :keyword properties: Properties of the build resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceProperties """ - super(BuildService, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildServiceAgentPoolProperties(msrest.serialization.Model): +class BuildServiceAgentPoolProperties(_serialization.Model): """Build service agent pool properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1807,26 +1680,21 @@ class BuildServiceAgentPoolProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'pool_size': {'key': 'poolSize', 'type': 'BuildServiceAgentPoolSizeProperties'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "pool_size": {"key": "poolSize", "type": "BuildServiceAgentPoolSizeProperties"}, } - def __init__( - self, - *, - pool_size: Optional["BuildServiceAgentPoolSizeProperties"] = None, - **kwargs - ): + def __init__(self, *, pool_size: Optional["_models.BuildServiceAgentPoolSizeProperties"] = None, **kwargs): """ :keyword pool_size: build service agent pool size properties. :paramtype pool_size: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolSizeProperties """ - super(BuildServiceAgentPoolProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.pool_size = pool_size @@ -1850,36 +1718,31 @@ class BuildServiceAgentPoolResource(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': 'BuildServiceAgentPoolProperties'}, + "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": "BuildServiceAgentPoolProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildServiceAgentPoolProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildServiceAgentPoolProperties"] = None, **kwargs): """ :keyword properties: build service agent pool properties. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolProperties """ - super(BuildServiceAgentPoolResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildServiceAgentPoolResourceCollection(msrest.serialization.Model): +class BuildServiceAgentPoolResourceCollection(_serialization.Model): """Object that includes an array of build service agent pool resources and a possible link for next set. :ivar value: Collection of build service agent pool resource. @@ -1891,14 +1754,14 @@ class BuildServiceAgentPoolResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildServiceAgentPoolResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildServiceAgentPoolResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["BuildServiceAgentPoolResource"]] = None, + value: Optional[List["_models.BuildServiceAgentPoolResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1910,12 +1773,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildServiceAgentPoolResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildServiceAgentPoolSizeProperties(msrest.serialization.Model): +class BuildServiceAgentPoolSizeProperties(_serialization.Model): """Build service agent pool size properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1929,33 +1792,28 @@ class BuildServiceAgentPoolSizeProperties(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The name of build service agent pool size. :paramtype name: str """ - super(BuildServiceAgentPoolSizeProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.cpu = None self.memory = None -class BuildServiceCollection(msrest.serialization.Model): +class BuildServiceCollection(_serialization.Model): """Object that includes an array of Build service resources and a possible link for next set. :ivar value: Collection of Build service resources. @@ -1966,16 +1824,12 @@ class BuildServiceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildService]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildService]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BuildService"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BuildService"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Build service resources. @@ -1984,20 +1838,20 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildServiceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildServiceProperties(msrest.serialization.Model): +class BuildServiceProperties(_serialization.Model): """Build service resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. :ivar k_pack_version: The installed KPack version in this build service. :vartype k_pack_version: str - :ivar provisioning_state: Provisioning state of the KPack build result. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceProvisioningState :ivar resource_requests: The runtime resource configuration of this build service. @@ -2006,20 +1860,20 @@ class BuildServiceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'k_pack_version': {'key': 'kPackVersion', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'BuildServicePropertiesResourceRequests'}, + "k_pack_version": {"key": "kPackVersion", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "BuildServicePropertiesResourceRequests"}, } def __init__( self, *, k_pack_version: Optional[str] = None, - resource_requests: Optional["BuildServicePropertiesResourceRequests"] = None, + resource_requests: Optional["_models.BuildServicePropertiesResourceRequests"] = None, **kwargs ): """ @@ -2029,13 +1883,13 @@ def __init__( :paramtype resource_requests: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServicePropertiesResourceRequests """ - super(BuildServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.k_pack_version = k_pack_version self.provisioning_state = None self.resource_requests = resource_requests -class BuildServicePropertiesResourceRequests(msrest.serialization.Model): +class BuildServicePropertiesResourceRequests(_serialization.Model): """The runtime resource configuration of this build service. Variables are only populated by the server, and will be ignored when sending a request. @@ -2047,71 +1901,63 @@ class BuildServicePropertiesResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BuildServicePropertiesResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None -class BuildStageProperties(msrest.serialization.Model): +class BuildStageProperties(_serialization.Model): """The build stage (init-container and container) resources in build pod. Variables are only populated by the server, and will be ignored when sending a request. :ivar name: The name of this build stage resource. :vartype name: str - :ivar status: The provisioning state of this build stage resource. Possible values include: - "NotStarted", "Running", "Succeeded", "Failed". + :ivar status: The provisioning state of this build stage resource. Known values are: + "NotStarted", "Running", "Succeeded", and "Failed". :vartype status: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.KPackBuildStageProvisioningState """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BuildStageProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """Certificate resource payload. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ContentCertificateProperties, KeyVaultCertificateProperties. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContentCertificateProperties, KeyVaultCertificateProperties Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -2130,38 +1976,37 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, } _subtype_map = { - 'type': {'ContentCertificate': 'ContentCertificateProperties', 'KeyVaultCertificate': 'KeyVaultCertificateProperties'} + "type": { + "ContentCertificate": "ContentCertificateProperties", + "KeyVaultCertificate": "KeyVaultCertificateProperties", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificateProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None # type: Optional[str] self.thumbprint = None self.issuer = None @@ -2190,35 +2035,30 @@ class CertificateResource(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': 'CertificateProperties'}, + "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": "CertificateProperties"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: Properties of the certificate resource payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateProperties """ - super(CertificateResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CertificateResourceCollection(msrest.serialization.Model): +class CertificateResourceCollection(_serialization.Model): """Collection compose of certificate resources list and a possible link for next page. :ivar value: The certificate resources list. @@ -2228,16 +2068,12 @@ class CertificateResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CertificateResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CertificateResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CertificateResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The certificate resources list. @@ -2245,12 +2081,12 @@ def __init__( :keyword next_link: The link to next page of certificate list. :paramtype next_link: str """ - super(CertificateResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -2267,10 +2103,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -2279,7 +2115,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -2295,21 +2131,21 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class ClusterResourceProperties(msrest.serialization.Model): +class ClusterResourceProperties(_serialization.Model): """Service properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Provisioning state of the Service. Possible values include: - "Creating", "Updating", "Starting", "Stopping", "Deleting", "Deleted", "Succeeded", "Failed", - "Moving", "Moved", "MoveFailed". + :ivar provisioning_state: Provisioning state of the Service. Known values are: "Creating", + "Updating", "Starting", "Stopping", "Deleting", "Deleted", "Succeeded", "Failed", "Moving", + "Moved", and "MoveFailed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.ProvisioningState :ivar network_profile: Network profile of the Service. @@ -2318,7 +2154,7 @@ class ClusterResourceProperties(msrest.serialization.Model): :vartype version: int :ivar service_id: ServiceInstanceEntity GUID which uniquely identifies a created resource. :vartype service_id: str - :ivar power_state: Power state of the Service. Possible values include: "Running", "Stopped". + :ivar power_state: Power state of the Service. Known values are: "Running" and "Stopped". :vartype power_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.PowerState :ivar zone_redundant: :vartype zone_redundant: bool @@ -2327,29 +2163,25 @@ class ClusterResourceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'version': {'readonly': True}, - 'service_id': {'readonly': True}, - 'power_state': {'readonly': True}, - 'fqdn': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "service_id": {"readonly": True}, + "power_state": {"readonly": True}, + "fqdn": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'network_profile': {'key': 'networkProfile', 'type': 'NetworkProfile'}, - 'version': {'key': 'version', 'type': 'int'}, - 'service_id': {'key': 'serviceId', 'type': 'str'}, - 'power_state': {'key': 'powerState', 'type': 'str'}, - 'zone_redundant': {'key': 'zoneRedundant', 'type': 'bool'}, - 'fqdn': {'key': 'fqdn', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "network_profile": {"key": "networkProfile", "type": "NetworkProfile"}, + "version": {"key": "version", "type": "int"}, + "service_id": {"key": "serviceId", "type": "str"}, + "power_state": {"key": "powerState", "type": "str"}, + "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, + "fqdn": {"key": "fqdn", "type": "str"}, } def __init__( - self, - *, - network_profile: Optional["NetworkProfile"] = None, - zone_redundant: Optional[bool] = False, - **kwargs + self, *, network_profile: Optional["_models.NetworkProfile"] = None, zone_redundant: bool = False, **kwargs ): """ :keyword network_profile: Network profile of the Service. @@ -2357,7 +2189,7 @@ def __init__( :keyword zone_redundant: :paramtype zone_redundant: bool """ - super(ClusterResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.network_profile = network_profile self.version = None @@ -2367,7 +2199,7 @@ def __init__( self.fqdn = None -class ConfigServerGitProperty(msrest.serialization.Model): +class ConfigServerGitProperty(_serialization.Model): """Property of git. All required parameters must be populated in order to send to Azure. @@ -2375,7 +2207,7 @@ class ConfigServerGitProperty(msrest.serialization.Model): :ivar repositories: Repositories of git. :vartype repositories: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.GitPatternRepository] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -2396,27 +2228,27 @@ class ConfigServerGitProperty(msrest.serialization.Model): """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'repositories': {'key': 'repositories', 'type': '[GitPatternRepository]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "repositories": {"key": "repositories", "type": "[GitPatternRepository]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( self, *, uri: str, - repositories: Optional[List["GitPatternRepository"]] = None, + repositories: Optional[List["_models.GitPatternRepository"]] = None, label: Optional[str] = None, search_paths: Optional[List[str]] = None, username: Optional[str] = None, @@ -2431,7 +2263,7 @@ def __init__( :keyword repositories: Repositories of git. :paramtype repositories: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.GitPatternRepository] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -2450,7 +2282,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(ConfigServerGitProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.repositories = repositories self.uri = uri self.label = label @@ -2463,13 +2295,13 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ConfigServerProperties(msrest.serialization.Model): +class ConfigServerProperties(_serialization.Model): """Config server git properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the config server. Possible values include: "NotAvailable", - "Deleted", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the config server. Known values are: "NotAvailable", + "Deleted", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerState :ivar error: Error when apply config server settings. @@ -2479,20 +2311,20 @@ class ConfigServerProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'config_server': {'key': 'configServer', 'type': 'ConfigServerSettings'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "config_server": {"key": "configServer", "type": "ConfigServerSettings"}, } def __init__( self, *, - error: Optional["Error"] = None, - config_server: Optional["ConfigServerSettings"] = None, + error: Optional["_models.Error"] = None, + config_server: Optional["_models.ConfigServerSettings"] = None, **kwargs ): """ @@ -2502,7 +2334,7 @@ def __init__( :paramtype config_server: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerSettings """ - super(ConfigServerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.config_server = config_server @@ -2526,36 +2358,31 @@ class ConfigServerResource(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': 'ConfigServerProperties'}, + "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": "ConfigServerProperties"}, } - def __init__( - self, - *, - properties: Optional["ConfigServerProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ConfigServerProperties"] = None, **kwargs): """ :keyword properties: Properties of the Config Server resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerProperties """ - super(ConfigServerResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ConfigServerSettings(msrest.serialization.Model): +class ConfigServerSettings(_serialization.Model): """The settings of config server. :ivar git_property: Property of git environment. @@ -2564,25 +2391,20 @@ class ConfigServerSettings(msrest.serialization.Model): """ _attribute_map = { - 'git_property': {'key': 'gitProperty', 'type': 'ConfigServerGitProperty'}, + "git_property": {"key": "gitProperty", "type": "ConfigServerGitProperty"}, } - def __init__( - self, - *, - git_property: Optional["ConfigServerGitProperty"] = None, - **kwargs - ): + def __init__(self, *, git_property: Optional["_models.ConfigServerGitProperty"] = None, **kwargs): """ :keyword git_property: Property of git environment. :paramtype git_property: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerGitProperty """ - super(ConfigServerSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property = git_property -class ConfigServerSettingsErrorRecord(msrest.serialization.Model): +class ConfigServerSettingsErrorRecord(_serialization.Model): """Error record of the config server settings. :ivar name: The name of the config server settings error record. @@ -2594,18 +2416,13 @@ class ConfigServerSettingsErrorRecord(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'messages': {'key': 'messages', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, } def __init__( - self, - *, - name: Optional[str] = None, - uri: Optional[str] = None, - messages: Optional[List[str]] = None, - **kwargs + self, *, name: Optional[str] = None, uri: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs ): """ :keyword name: The name of the config server settings error record. @@ -2615,13 +2432,13 @@ def __init__( :keyword messages: The detail error messages of the record. :paramtype messages: list[str] """ - super(ConfigServerSettingsErrorRecord, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.uri = uri self.messages = messages -class ConfigServerSettingsValidateResult(msrest.serialization.Model): +class ConfigServerSettingsValidateResult(_serialization.Model): """Validation result for config server settings. :ivar is_valid: Indicate if the config server settings are valid. @@ -2632,15 +2449,15 @@ class ConfigServerSettingsValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'details': {'key': 'details', 'type': '[ConfigServerSettingsErrorRecord]'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "details": {"key": "details", "type": "[ConfigServerSettingsErrorRecord]"}, } def __init__( self, *, is_valid: Optional[bool] = None, - details: Optional[List["ConfigServerSettingsErrorRecord"]] = None, + details: Optional[List["_models.ConfigServerSettingsErrorRecord"]] = None, **kwargs ): """ @@ -2650,12 +2467,12 @@ def __init__( :paramtype details: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerSettingsErrorRecord] """ - super(ConfigServerSettingsValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.details = details -class ConfigurationServiceGitProperty(msrest.serialization.Model): +class ConfigurationServiceGitProperty(_serialization.Model): """Property of git environment. :ivar repositories: Repositories of Application Configuration Service git property. @@ -2664,25 +2481,20 @@ class ConfigurationServiceGitProperty(msrest.serialization.Model): """ _attribute_map = { - 'repositories': {'key': 'repositories', 'type': '[ConfigurationServiceGitRepository]'}, + "repositories": {"key": "repositories", "type": "[ConfigurationServiceGitRepository]"}, } - def __init__( - self, - *, - repositories: Optional[List["ConfigurationServiceGitRepository"]] = None, - **kwargs - ): + def __init__(self, *, repositories: Optional[List["_models.ConfigurationServiceGitRepository"]] = None, **kwargs): """ :keyword repositories: Repositories of Application Configuration Service git property. :paramtype repositories: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceGitRepository] """ - super(ConfigurationServiceGitProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.repositories = repositories -class ConfigurationServiceGitPropertyValidateResult(msrest.serialization.Model): +class ConfigurationServiceGitPropertyValidateResult(_serialization.Model): """Validation result for configuration service settings. :ivar is_valid: Indicate if the configuration service settings are valid. @@ -2693,15 +2505,15 @@ class ConfigurationServiceGitPropertyValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'git_repos_validation_result': {'key': 'gitReposValidationResult', 'type': '[ValidationMessages]'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "git_repos_validation_result": {"key": "gitReposValidationResult", "type": "[ValidationMessages]"}, } def __init__( self, *, is_valid: Optional[bool] = None, - git_repos_validation_result: Optional[List["ValidationMessages"]] = None, + git_repos_validation_result: Optional[List["_models.ValidationMessages"]] = None, **kwargs ): """ @@ -2711,23 +2523,23 @@ def __init__( :paramtype git_repos_validation_result: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.ValidationMessages] """ - super(ConfigurationServiceGitPropertyValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.git_repos_validation_result = git_repos_validation_result -class ConfigurationServiceGitRepository(msrest.serialization.Model): +class ConfigurationServiceGitRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes """Git repository property payload for Application Configuration Service. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the repository. + :ivar name: Name of the repository. Required. :vartype name: str - :ivar patterns: Required. Collection of patterns of the repository. + :ivar patterns: Collection of patterns of the repository. Required. :vartype patterns: list[str] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str - :ivar label: Required. Label of the repository. + :ivar label: Label of the repository. Required. :vartype label: str :ivar search_paths: Searching path of the repository. :vartype search_paths: list[str] @@ -2746,24 +2558,24 @@ class ConfigurationServiceGitRepository(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'patterns': {'required': True}, - 'uri': {'required': True}, - 'label': {'required': True}, + "name": {"required": True}, + "patterns": {"required": True}, + "uri": {"required": True}, + "label": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'patterns': {'key': 'patterns', 'type': '[str]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "patterns": {"key": "patterns", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( @@ -2783,13 +2595,13 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of the repository. + :keyword name: Name of the repository. Required. :paramtype name: str - :keyword patterns: Required. Collection of patterns of the repository. + :keyword patterns: Collection of patterns of the repository. Required. :paramtype patterns: list[str] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str - :keyword label: Required. Label of the repository. + :keyword label: Label of the repository. Required. :paramtype label: str :keyword search_paths: Searching path of the repository. :paramtype search_paths: list[str] @@ -2806,7 +2618,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(ConfigurationServiceGitRepository, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.patterns = patterns self.uri = uri @@ -2820,7 +2632,7 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ConfigurationServiceInstance(msrest.serialization.Model): +class ConfigurationServiceInstance(_serialization.Model): """Collection of instances belong to the Application Configuration Service. Variables are only populated by the server, and will be ignored when sending a request. @@ -2832,33 +2644,29 @@ class ConfigurationServiceInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ConfigurationServiceInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class ConfigurationServiceProperties(msrest.serialization.Model): +class ConfigurationServiceProperties(_serialization.Model): """Application Configuration Service properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Application Configuration Service. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Application Configuration Service. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceProvisioningState :ivar resource_requests: The requested resource quantity for required CPU and Memory. @@ -2873,30 +2681,25 @@ class ConfigurationServiceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'resource_requests': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'ConfigurationServiceResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[ConfigurationServiceInstance]'}, - 'settings': {'key': 'settings', 'type': 'ConfigurationServiceSettings'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "ConfigurationServiceResourceRequests"}, + "instances": {"key": "instances", "type": "[ConfigurationServiceInstance]"}, + "settings": {"key": "settings", "type": "ConfigurationServiceSettings"}, } - def __init__( - self, - *, - settings: Optional["ConfigurationServiceSettings"] = None, - **kwargs - ): + def __init__(self, *, settings: Optional["_models.ConfigurationServiceSettings"] = None, **kwargs): """ :keyword settings: The settings of Application Configuration Service. :paramtype settings: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceSettings """ - super(ConfigurationServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.resource_requests = None self.instances = None @@ -2922,36 +2725,31 @@ class ConfigurationServiceResource(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': 'ConfigurationServiceProperties'}, + "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": "ConfigurationServiceProperties"}, } - def __init__( - self, - *, - properties: Optional["ConfigurationServiceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ConfigurationServiceProperties"] = None, **kwargs): """ :keyword properties: Application Configuration Service properties payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceProperties """ - super(ConfigurationServiceResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ConfigurationServiceResourceCollection(msrest.serialization.Model): +class ConfigurationServiceResourceCollection(_serialization.Model): """Object that includes an array of configuration service resources and a possible link for next set. :ivar value: Collection of configuration service resources. @@ -2963,14 +2761,14 @@ class ConfigurationServiceResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ConfigurationServiceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ConfigurationServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ConfigurationServiceResource"]] = None, + value: Optional[List["_models.ConfigurationServiceResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2982,12 +2780,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ConfigurationServiceResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ConfigurationServiceResourceRequests(msrest.serialization.Model): +class ConfigurationServiceResourceRequests(_serialization.Model): """Resource request payload of Application Configuration Service. Variables are only populated by the server, and will be ignored when sending a request. @@ -3001,30 +2799,26 @@ class ConfigurationServiceResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, - 'instance_count': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ConfigurationServiceResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None self.instance_count = None -class ConfigurationServiceSettings(msrest.serialization.Model): +class ConfigurationServiceSettings(_serialization.Model): """The settings of Application Configuration Service. :ivar git_property: Property of git environment. @@ -3033,25 +2827,20 @@ class ConfigurationServiceSettings(msrest.serialization.Model): """ _attribute_map = { - 'git_property': {'key': 'gitProperty', 'type': 'ConfigurationServiceGitProperty'}, + "git_property": {"key": "gitProperty", "type": "ConfigurationServiceGitProperty"}, } - def __init__( - self, - *, - git_property: Optional["ConfigurationServiceGitProperty"] = None, - **kwargs - ): + def __init__(self, *, git_property: Optional["_models.ConfigurationServiceGitProperty"] = None, **kwargs): """ :keyword git_property: Property of git environment. :paramtype git_property: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceGitProperty """ - super(ConfigurationServiceSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property = git_property -class ConfigurationServiceSettingsValidateResult(msrest.serialization.Model): +class ConfigurationServiceSettingsValidateResult(_serialization.Model): """Validation result for configuration service settings. :ivar git_property_validation_result: Validation result for configuration service settings. @@ -3060,13 +2849,16 @@ class ConfigurationServiceSettingsValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'git_property_validation_result': {'key': 'gitPropertyValidationResult', 'type': 'ConfigurationServiceGitPropertyValidateResult'}, + "git_property_validation_result": { + "key": "gitPropertyValidationResult", + "type": "ConfigurationServiceGitPropertyValidateResult", + }, } def __init__( self, *, - git_property_validation_result: Optional["ConfigurationServiceGitPropertyValidateResult"] = None, + git_property_validation_result: Optional["_models.ConfigurationServiceGitPropertyValidateResult"] = None, **kwargs ): """ @@ -3074,11 +2866,11 @@ def __init__( :paramtype git_property_validation_result: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceGitPropertyValidateResult """ - super(ConfigurationServiceSettingsValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property_validation_result = git_property_validation_result -class ContainerProbeSettings(msrest.serialization.Model): +class ContainerProbeSettings(_serialization.Model): """Container liveness and readiness probe settings. :ivar disable_probe: Indicates whether disable the liveness and readiness probe. @@ -3086,20 +2878,15 @@ class ContainerProbeSettings(msrest.serialization.Model): """ _attribute_map = { - 'disable_probe': {'key': 'disableProbe', 'type': 'bool'}, + "disable_probe": {"key": "disableProbe", "type": "bool"}, } - def __init__( - self, - *, - disable_probe: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, disable_probe: Optional[bool] = None, **kwargs): """ :keyword disable_probe: Indicates whether disable the liveness and readiness probe. :paramtype disable_probe: bool """ - super(ContainerProbeSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.disable_probe = disable_probe @@ -3110,7 +2897,7 @@ class ContentCertificateProperties(CertificateProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -3131,44 +2918,39 @@ class ContentCertificateProperties(CertificateProperties): """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, - 'content': {'key': 'content', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "content": {"key": "content", "type": "str"}, } - def __init__( - self, - *, - content: Optional[str] = None, - **kwargs - ): + def __init__(self, *, content: Optional[str] = None, **kwargs): """ :keyword content: The content of uploaded certificate. :paramtype content: str """ - super(ContentCertificateProperties, self).__init__(**kwargs) - self.type = 'ContentCertificate' # type: str + super().__init__(**kwargs) + self.type = "ContentCertificate" # type: str self.content = content -class CustomContainer(msrest.serialization.Model): +class CustomContainer(_serialization.Model): """Custom container payload. :ivar server: The name of the registry that contains the container image. @@ -3188,11 +2970,11 @@ class CustomContainer(msrest.serialization.Model): """ _attribute_map = { - 'server': {'key': 'server', 'type': 'str'}, - 'container_image': {'key': 'containerImage', 'type': 'str'}, - 'command': {'key': 'command', 'type': '[str]'}, - 'args': {'key': 'args', 'type': '[str]'}, - 'image_registry_credential': {'key': 'imageRegistryCredential', 'type': 'ImageRegistryCredential'}, + "server": {"key": "server", "type": "str"}, + "container_image": {"key": "containerImage", "type": "str"}, + "command": {"key": "command", "type": "[str]"}, + "args": {"key": "args", "type": "[str]"}, + "image_registry_credential": {"key": "imageRegistryCredential", "type": "ImageRegistryCredential"}, } def __init__( @@ -3202,7 +2984,7 @@ def __init__( container_image: Optional[str] = None, command: Optional[List[str]] = None, args: Optional[List[str]] = None, - image_registry_credential: Optional["ImageRegistryCredential"] = None, + image_registry_credential: Optional["_models.ImageRegistryCredential"] = None, **kwargs ): """ @@ -3221,7 +3003,7 @@ def __init__( :paramtype image_registry_credential: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ImageRegistryCredential """ - super(CustomContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.server = server self.container_image = container_image self.command = command @@ -3234,7 +3016,7 @@ class CustomContainerUserSourceInfo(UserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -3243,21 +3025,17 @@ class CustomContainerUserSourceInfo(UserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'custom_container': {'key': 'customContainer', 'type': 'CustomContainer'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "custom_container": {"key": "customContainer", "type": "CustomContainer"}, } def __init__( - self, - *, - version: Optional[str] = None, - custom_container: Optional["CustomContainer"] = None, - **kwargs + self, *, version: Optional[str] = None, custom_container: Optional["_models.CustomContainer"] = None, **kwargs ): """ :keyword version: Version of the source. @@ -3265,12 +3043,12 @@ def __init__( :keyword custom_container: Custom container payload. :paramtype custom_container: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomContainer """ - super(CustomContainerUserSourceInfo, self).__init__(version=version, **kwargs) - self.type = 'Container' # type: str + super().__init__(version=version, **kwargs) + self.type = "Container" # type: str self.custom_container = custom_container -class CustomDomainProperties(msrest.serialization.Model): +class CustomDomainProperties(_serialization.Model): """Custom domain of app resource payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -3284,29 +3062,23 @@ class CustomDomainProperties(msrest.serialization.Model): """ _validation = { - 'app_name': {'readonly': True}, + "app_name": {"readonly": True}, } _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'app_name': {'key': 'appName', 'type': 'str'}, - 'cert_name': {'key': 'certName', 'type': 'str'}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "app_name": {"key": "appName", "type": "str"}, + "cert_name": {"key": "certName", "type": "str"}, } - def __init__( - self, - *, - thumbprint: Optional[str] = None, - cert_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, thumbprint: Optional[str] = None, cert_name: Optional[str] = None, **kwargs): """ :keyword thumbprint: The thumbprint of bound certificate. :paramtype thumbprint: str :keyword cert_name: The bound certificate name of domain. :paramtype cert_name: str """ - super(CustomDomainProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = thumbprint self.app_name = None self.cert_name = cert_name @@ -3330,36 +3102,31 @@ class CustomDomainResource(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': 'CustomDomainProperties'}, + "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": "CustomDomainProperties"}, } - def __init__( - self, - *, - properties: Optional["CustomDomainProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CustomDomainProperties"] = None, **kwargs): """ :keyword properties: Properties of the custom domain resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainProperties """ - super(CustomDomainResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CustomDomainResourceCollection(msrest.serialization.Model): +class CustomDomainResourceCollection(_serialization.Model): """Collection compose of a custom domain resources list and a possible link for next page. :ivar value: The custom domain resources list. @@ -3369,16 +3136,12 @@ class CustomDomainResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CustomDomainResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CustomDomainResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The custom domain resources list. @@ -3386,43 +3149,38 @@ def __init__( :keyword next_link: The link to next page of custom domain list. :paramtype next_link: str """ - super(CustomDomainResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CustomDomainValidatePayload(msrest.serialization.Model): +class CustomDomainValidatePayload(_serialization.Model): """Custom domain validate payload. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name to be validated. + :ivar name: Name to be validated. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Name to be validated. + :keyword name: Name to be validated. Required. :paramtype name: str """ - super(CustomDomainValidatePayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CustomDomainValidateResult(msrest.serialization.Model): +class CustomDomainValidateResult(_serialization.Model): """Validation result for custom domain. :ivar is_valid: Indicates if domain name is valid. @@ -3432,29 +3190,23 @@ class CustomDomainValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'message': {'key': 'message', 'type': 'str'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - is_valid: Optional[bool] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, is_valid: Optional[bool] = None, message: Optional[str] = None, **kwargs): """ :keyword is_valid: Indicates if domain name is valid. :paramtype is_valid: bool :keyword message: Message of why domain name is invalid. :paramtype message: str """ - super(CustomDomainValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.message = message -class CustomPersistentDiskResource(msrest.serialization.Model): +class CustomPersistentDiskResource(_serialization.Model): """Custom persistent disk resource payload. All required parameters must be populated in order to send to Azure. @@ -3463,24 +3215,27 @@ class CustomPersistentDiskResource(msrest.serialization.Model): payload. :vartype custom_persistent_disk_properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomPersistentDiskProperties - :ivar storage_id: Required. The resource id of Azure Spring Cloud Storage resource. + :ivar storage_id: The resource id of Azure Spring Cloud Storage resource. Required. :vartype storage_id: str """ _validation = { - 'storage_id': {'required': True}, + "storage_id": {"required": True}, } _attribute_map = { - 'custom_persistent_disk_properties': {'key': 'customPersistentDiskProperties', 'type': 'CustomPersistentDiskProperties'}, - 'storage_id': {'key': 'storageId', 'type': 'str'}, + "custom_persistent_disk_properties": { + "key": "customPersistentDiskProperties", + "type": "CustomPersistentDiskProperties", + }, + "storage_id": {"key": "storageId", "type": "str"}, } def __init__( self, *, storage_id: str, - custom_persistent_disk_properties: Optional["CustomPersistentDiskProperties"] = None, + custom_persistent_disk_properties: Optional["_models.CustomPersistentDiskProperties"] = None, **kwargs ): """ @@ -3488,15 +3243,15 @@ def __init__( payload. :paramtype custom_persistent_disk_properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomPersistentDiskProperties - :keyword storage_id: Required. The resource id of Azure Spring Cloud Storage resource. + :keyword storage_id: The resource id of Azure Spring Cloud Storage resource. Required. :paramtype storage_id: str """ - super(CustomPersistentDiskResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.custom_persistent_disk_properties = custom_persistent_disk_properties self.storage_id = storage_id -class DeploymentInstance(msrest.serialization.Model): +class DeploymentInstance(_serialization.Model): """Deployment instance payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -3516,30 +3271,26 @@ class DeploymentInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, - 'reason': {'readonly': True}, - 'discovery_status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'zone': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, + "reason": {"readonly": True}, + "discovery_status": {"readonly": True}, + "start_time": {"readonly": True}, + "zone": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'discovery_status': {'key': 'discoveryStatus', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'zone': {'key': 'zone', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "discovery_status": {"key": "discoveryStatus", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, + "zone": {"key": "zone", "type": "str"}, } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentInstance, self).__init__(**kwargs) + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None self.reason = None @@ -3569,26 +3320,26 @@ class DeploymentResource(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': 'DeploymentResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "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": "DeploymentResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( self, *, - properties: Optional["DeploymentResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.DeploymentResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -3598,12 +3349,12 @@ def __init__( :keyword sku: Sku of the Deployment resource. :paramtype sku: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Sku """ - super(DeploymentResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.sku = sku -class DeploymentResourceCollection(msrest.serialization.Model): +class DeploymentResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of Deployment resources. @@ -3614,16 +3365,12 @@ class DeploymentResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["DeploymentResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.DeploymentResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Deployment resources. @@ -3632,12 +3379,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(DeploymentResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class DeploymentResourceProperties(msrest.serialization.Model): +class DeploymentResourceProperties(_serialization.Model): """Deployment resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -3647,11 +3394,11 @@ class DeploymentResourceProperties(msrest.serialization.Model): :ivar deployment_settings: Deployment settings of the Deployment. :vartype deployment_settings: ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentSettings - :ivar provisioning_state: Provisioning state of the Deployment. Possible values include: - "Creating", "Updating", "Succeeded", "Failed". + :ivar provisioning_state: Provisioning state of the Deployment. Known values are: "Creating", + "Updating", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResourceProvisioningState - :ivar status: Status of the Deployment. Possible values include: "Stopped", "Running". + :ivar status: Status of the Deployment. Known values are: "Stopped" and "Running". :vartype status: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResourceStatus :ivar active: Indicates whether the Deployment is active. @@ -3661,25 +3408,25 @@ class DeploymentResourceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'UserSourceInfo'}, - 'deployment_settings': {'key': 'deploymentSettings', 'type': 'DeploymentSettings'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'active': {'key': 'active', 'type': 'bool'}, - 'instances': {'key': 'instances', 'type': '[DeploymentInstance]'}, + "source": {"key": "source", "type": "UserSourceInfo"}, + "deployment_settings": {"key": "deploymentSettings", "type": "DeploymentSettings"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "active": {"key": "active", "type": "bool"}, + "instances": {"key": "instances", "type": "[DeploymentInstance]"}, } def __init__( self, *, - source: Optional["UserSourceInfo"] = None, - deployment_settings: Optional["DeploymentSettings"] = None, + source: Optional["_models.UserSourceInfo"] = None, + deployment_settings: Optional["_models.DeploymentSettings"] = None, active: Optional[bool] = None, **kwargs ): @@ -3692,7 +3439,7 @@ def __init__( :keyword active: Indicates whether the Deployment is active. :paramtype active: bool """ - super(DeploymentResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.deployment_settings = deployment_settings self.provisioning_state = None @@ -3701,7 +3448,7 @@ def __init__( self.instances = None -class DeploymentSettings(msrest.serialization.Model): +class DeploymentSettings(_serialization.Model): """Deployment settings payload. :ivar resource_requests: The requested resource quantity for required CPU and Memory. It is @@ -3711,26 +3458,26 @@ class DeploymentSettings(msrest.serialization.Model): :ivar environment_variables: Collection of environment variables. :vartype environment_variables: dict[str, str] :ivar addon_configs: Collection of addons. - :vartype addon_configs: dict[str, dict[str, any]] + :vartype addon_configs: dict[str, dict[str, JSON]] :ivar container_probe_settings: Container liveness and readiness probe settings. :vartype container_probe_settings: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ContainerProbeSettings """ _attribute_map = { - 'resource_requests': {'key': 'resourceRequests', 'type': 'ResourceRequests'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '{str}'}, - 'addon_configs': {'key': 'addonConfigs', 'type': '{{object}}'}, - 'container_probe_settings': {'key': 'containerProbeSettings', 'type': 'ContainerProbeSettings'}, + "resource_requests": {"key": "resourceRequests", "type": "ResourceRequests"}, + "environment_variables": {"key": "environmentVariables", "type": "{str}"}, + "addon_configs": {"key": "addonConfigs", "type": "{{object}}"}, + "container_probe_settings": {"key": "containerProbeSettings", "type": "ContainerProbeSettings"}, } def __init__( self, *, - resource_requests: Optional["ResourceRequests"] = None, + resource_requests: Optional["_models.ResourceRequests"] = None, environment_variables: Optional[Dict[str, str]] = None, - addon_configs: Optional[Dict[str, Dict[str, Any]]] = None, - container_probe_settings: Optional["ContainerProbeSettings"] = None, + addon_configs: Optional[Dict[str, Dict[str, JSON]]] = None, + container_probe_settings: Optional["_models.ContainerProbeSettings"] = None, **kwargs ): """ @@ -3742,19 +3489,19 @@ def __init__( :keyword environment_variables: Collection of environment variables. :paramtype environment_variables: dict[str, str] :keyword addon_configs: Collection of addons. - :paramtype addon_configs: dict[str, dict[str, any]] + :paramtype addon_configs: dict[str, dict[str, JSON]] :keyword container_probe_settings: Container liveness and readiness probe settings. :paramtype container_probe_settings: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ContainerProbeSettings """ - super(DeploymentSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_requests = resource_requests self.environment_variables = environment_variables self.addon_configs = addon_configs self.container_probe_settings = container_probe_settings -class DiagnosticParameters(msrest.serialization.Model): +class DiagnosticParameters(_serialization.Model): """Diagnostic parameters of diagnostic operations. :ivar app_instance: App instance name. @@ -3766,9 +3513,9 @@ class DiagnosticParameters(msrest.serialization.Model): """ _attribute_map = { - 'app_instance': {'key': 'appInstance', 'type': 'str'}, - 'file_path': {'key': 'filePath', 'type': 'str'}, - 'duration': {'key': 'duration', 'type': 'str'}, + "app_instance": {"key": "appInstance", "type": "str"}, + "file_path": {"key": "filePath", "type": "str"}, + "duration": {"key": "duration", "type": "str"}, } def __init__( @@ -3787,13 +3534,13 @@ def __init__( :keyword duration: Duration of your JFR. 1 min can be represented by 1m or 60s. :paramtype duration: str """ - super(DiagnosticParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.app_instance = app_instance self.file_path = file_path self.duration = duration -class Error(msrest.serialization.Model): +class Error(_serialization.Model): """The error code compose of code and message. :ivar code: The code of error. @@ -3803,29 +3550,23 @@ class Error(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: The code of error. :paramtype code: str :keyword message: The message of error. :paramtype message: str """ - super(Error, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class GatewayApiMetadataProperties(msrest.serialization.Model): +class GatewayApiMetadataProperties(_serialization.Model): """API metadata property for Spring Cloud Gateway. :ivar title: Title describing the context of the APIs available on the Gateway instance @@ -3844,11 +3585,11 @@ class GatewayApiMetadataProperties(msrest.serialization.Model): """ _attribute_map = { - 'title': {'key': 'title', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'documentation': {'key': 'documentation', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'server_url': {'key': 'serverUrl', 'type': 'str'}, + "title": {"key": "title", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "documentation": {"key": "documentation", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "server_url": {"key": "serverUrl", "type": "str"}, } def __init__( @@ -3878,7 +3619,7 @@ def __init__( instance. :paramtype server_url: str """ - super(GatewayApiMetadataProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.title = title self.description = description self.documentation = documentation @@ -3886,7 +3627,7 @@ def __init__( self.server_url = server_url -class GatewayApiRoute(msrest.serialization.Model): +class GatewayApiRoute(_serialization.Model): """API route config of the Spring Cloud Gateway. :ivar title: A title, will be applied to methods in the generated OpenAPI documentation. @@ -3910,21 +3651,21 @@ class GatewayApiRoute(msrest.serialization.Model): :vartype filters: list[str] :ivar order: Route processing order. :vartype order: int - :ivar tags: A set of tags. Classification tags, will be applied to methods in the generated - OpenAPI documentation. + :ivar tags: Classification tags, will be applied to methods in the generated OpenAPI + documentation. :vartype tags: list[str] """ _attribute_map = { - 'title': {'key': 'title', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'sso_enabled': {'key': 'ssoEnabled', 'type': 'bool'}, - 'token_relay': {'key': 'tokenRelay', 'type': 'bool'}, - 'predicates': {'key': 'predicates', 'type': '[str]'}, - 'filters': {'key': 'filters', 'type': '[str]'}, - 'order': {'key': 'order', 'type': 'int'}, - 'tags': {'key': 'tags', 'type': '[str]'}, + "title": {"key": "title", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "sso_enabled": {"key": "ssoEnabled", "type": "bool"}, + "token_relay": {"key": "tokenRelay", "type": "bool"}, + "predicates": {"key": "predicates", "type": "[str]"}, + "filters": {"key": "filters", "type": "[str]"}, + "order": {"key": "order", "type": "int"}, + "tags": {"key": "tags", "type": "[str]"}, } def __init__( @@ -3963,11 +3704,11 @@ def __init__( :paramtype filters: list[str] :keyword order: Route processing order. :paramtype order: int - :keyword tags: A set of tags. Classification tags, will be applied to methods in the generated - OpenAPI documentation. + :keyword tags: Classification tags, will be applied to methods in the generated OpenAPI + documentation. :paramtype tags: list[str] """ - super(GatewayApiRoute, self).__init__(**kwargs) + super().__init__(**kwargs) self.title = title self.description = description self.uri = uri @@ -3979,7 +3720,7 @@ def __init__( self.tags = tags -class GatewayCorsProperties(msrest.serialization.Model): +class GatewayCorsProperties(_serialization.Model): """Cross-Origin Resource Sharing property. :ivar allowed_origins: Allowed origins to make cross-site requests. The special value ``*`` @@ -4002,12 +3743,12 @@ class GatewayCorsProperties(msrest.serialization.Model): """ _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, - 'max_age': {'key': 'maxAge', 'type': 'int'}, - 'allow_credentials': {'key': 'allowCredentials', 'type': 'bool'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, + "max_age": {"key": "maxAge", "type": "int"}, + "allow_credentials": {"key": "allowCredentials", "type": "bool"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, } def __init__( @@ -4040,7 +3781,7 @@ def __init__( :keyword exposed_headers: HTTP response headers to expose for cross-site requests. :paramtype exposed_headers: list[str] """ - super(GatewayCorsProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.allowed_headers = allowed_headers @@ -4049,7 +3790,7 @@ def __init__( self.exposed_headers = exposed_headers -class GatewayCustomDomainProperties(msrest.serialization.Model): +class GatewayCustomDomainProperties(_serialization.Model): """The properties of custom domain for Spring Cloud Gateway. :ivar thumbprint: The thumbprint of bound certificate. @@ -4057,20 +3798,15 @@ class GatewayCustomDomainProperties(msrest.serialization.Model): """ _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, + "thumbprint": {"key": "thumbprint", "type": "str"}, } - def __init__( - self, - *, - thumbprint: Optional[str] = None, - **kwargs - ): + def __init__(self, *, thumbprint: Optional[str] = None, **kwargs): """ :keyword thumbprint: The thumbprint of bound certificate. :paramtype thumbprint: str """ - super(GatewayCustomDomainProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = thumbprint @@ -4093,36 +3829,31 @@ class GatewayCustomDomainResource(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': 'GatewayCustomDomainProperties'}, + "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": "GatewayCustomDomainProperties"}, } - def __init__( - self, - *, - properties: Optional["GatewayCustomDomainProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.GatewayCustomDomainProperties"] = None, **kwargs): """ :keyword properties: The properties of custom domain for Spring Cloud Gateway. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainProperties """ - super(GatewayCustomDomainResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class GatewayCustomDomainResourceCollection(msrest.serialization.Model): +class GatewayCustomDomainResourceCollection(_serialization.Model): """Object that includes an array of Spring Cloud Gateway custom domain resources and a possible link for next set. :ivar value: Collection of Spring Cloud Gateway custom domain resources. @@ -4134,14 +3865,14 @@ class GatewayCustomDomainResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayCustomDomainResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GatewayCustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["GatewayCustomDomainResource"]] = None, + value: Optional[List["_models.GatewayCustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -4153,12 +3884,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(GatewayCustomDomainResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class GatewayInstance(msrest.serialization.Model): +class GatewayInstance(_serialization.Model): """Collection of instances belong to the Spring Cloud Gateway. Variables are only populated by the server, and will be ignored when sending a request. @@ -4170,27 +3901,23 @@ class GatewayInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GatewayInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class GatewayOperatorProperties(msrest.serialization.Model): +class GatewayOperatorProperties(_serialization.Model): """Properties of the Spring Cloud Gateway Operator. Variables are only populated by the server, and will be ignored when sending a request. @@ -4203,27 +3930,23 @@ class GatewayOperatorProperties(msrest.serialization.Model): """ _validation = { - 'resource_requests': {'readonly': True}, - 'instances': {'readonly': True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'resource_requests': {'key': 'resourceRequests', 'type': 'GatewayOperatorResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[GatewayInstance]'}, + "resource_requests": {"key": "resourceRequests", "type": "GatewayOperatorResourceRequests"}, + "instances": {"key": "instances", "type": "[GatewayInstance]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GatewayOperatorProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_requests = None self.instances = None -class GatewayOperatorResourceRequests(msrest.serialization.Model): +class GatewayOperatorResourceRequests(_serialization.Model): """Properties of the Spring Cloud Gateway Operator. Variables are only populated by the server, and will be ignored when sending a request. @@ -4237,36 +3960,32 @@ class GatewayOperatorResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, - 'instance_count': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GatewayOperatorResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None self.instance_count = None -class GatewayProperties(msrest.serialization.Model): +class GatewayProperties(_serialization.Model): """Spring Cloud Gateway properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Spring Cloud Gateway. Possible values include: - "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Spring Cloud Gateway. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayProvisioningState :ivar public: Indicates whether the Spring Cloud Gateway exposes endpoint. @@ -4294,34 +4013,34 @@ class GatewayProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'url': {'readonly': True}, - 'instances': {'readonly': True}, - 'operator_properties': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "url": {"readonly": True}, + "instances": {"readonly": True}, + "operator_properties": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'public': {'key': 'public', 'type': 'bool'}, - 'url': {'key': 'url', 'type': 'str'}, - 'https_only': {'key': 'httpsOnly', 'type': 'bool'}, - 'sso_properties': {'key': 'ssoProperties', 'type': 'SsoProperties'}, - 'api_metadata_properties': {'key': 'apiMetadataProperties', 'type': 'GatewayApiMetadataProperties'}, - 'cors_properties': {'key': 'corsProperties', 'type': 'GatewayCorsProperties'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'GatewayResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[GatewayInstance]'}, - 'operator_properties': {'key': 'operatorProperties', 'type': 'GatewayOperatorProperties'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "sso_properties": {"key": "ssoProperties", "type": "SsoProperties"}, + "api_metadata_properties": {"key": "apiMetadataProperties", "type": "GatewayApiMetadataProperties"}, + "cors_properties": {"key": "corsProperties", "type": "GatewayCorsProperties"}, + "resource_requests": {"key": "resourceRequests", "type": "GatewayResourceRequests"}, + "instances": {"key": "instances", "type": "[GatewayInstance]"}, + "operator_properties": {"key": "operatorProperties", "type": "GatewayOperatorProperties"}, } def __init__( self, *, - public: Optional[bool] = False, - https_only: Optional[bool] = False, - sso_properties: Optional["SsoProperties"] = None, - api_metadata_properties: Optional["GatewayApiMetadataProperties"] = None, - cors_properties: Optional["GatewayCorsProperties"] = None, - resource_requests: Optional["GatewayResourceRequests"] = None, + public: bool = False, + https_only: bool = False, + sso_properties: Optional["_models.SsoProperties"] = None, + api_metadata_properties: Optional["_models.GatewayApiMetadataProperties"] = None, + cors_properties: Optional["_models.GatewayCorsProperties"] = None, + resource_requests: Optional["_models.GatewayResourceRequests"] = None, **kwargs ): """ @@ -4341,7 +4060,7 @@ def __init__( :paramtype resource_requests: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResourceRequests """ - super(GatewayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.public = public self.url = None @@ -4374,27 +4093,23 @@ class GatewayResource(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': 'GatewayProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "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": "GatewayProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( - self, - *, - properties: Optional["GatewayProperties"] = None, - sku: Optional["Sku"] = None, - **kwargs + self, *, properties: Optional["_models.GatewayProperties"] = None, sku: Optional["_models.Sku"] = None, **kwargs ): """ :keyword properties: Spring Cloud Gateway properties payload. @@ -4402,12 +4117,12 @@ def __init__( :keyword sku: Sku of the Spring Cloud Gateway resource. :paramtype sku: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Sku """ - super(GatewayResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.sku = sku -class GatewayResourceCollection(msrest.serialization.Model): +class GatewayResourceCollection(_serialization.Model): """Object that includes an array of gateway resources and a possible link for next set. :ivar value: Collection of gateway resources. @@ -4418,16 +4133,12 @@ class GatewayResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GatewayResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["GatewayResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.GatewayResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of gateway resources. @@ -4436,12 +4147,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(GatewayResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class GatewayResourceRequests(msrest.serialization.Model): +class GatewayResourceRequests(_serialization.Model): """Resource request payload of Spring Cloud Gateway. :ivar cpu: Cpu allocated to each Spring Cloud Gateway instance. @@ -4451,35 +4162,29 @@ class GatewayResourceRequests(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - *, - cpu: Optional[str] = None, - memory: Optional[str] = None, - **kwargs - ): + def __init__(self, *, cpu: str = "1", memory: str = "2Gi", **kwargs): """ :keyword cpu: Cpu allocated to each Spring Cloud Gateway instance. :paramtype cpu: str :keyword memory: Memory allocated to each Spring Cloud Gateway instance. :paramtype memory: str """ - super(GatewayResourceRequests, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory = memory -class GatewayRouteConfigProperties(msrest.serialization.Model): +class GatewayRouteConfigProperties(_serialization.Model): """API route config of the Spring Cloud Gateway. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Spring Cloud Gateway route config. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Spring Cloud Gateway route config. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayProvisioningState :ivar app_resource_id: The resource Id of the Azure Spring Cloud app, required unless route @@ -4491,20 +4196,20 @@ class GatewayRouteConfigProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'app_resource_id': {'key': 'appResourceId', 'type': 'str'}, - 'routes': {'key': 'routes', 'type': '[GatewayApiRoute]'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "app_resource_id": {"key": "appResourceId", "type": "str"}, + "routes": {"key": "routes", "type": "[GatewayApiRoute]"}, } def __init__( self, *, app_resource_id: Optional[str] = None, - routes: Optional[List["GatewayApiRoute"]] = None, + routes: Optional[List["_models.GatewayApiRoute"]] = None, **kwargs ): """ @@ -4515,7 +4220,7 @@ def __init__( ``uri``\ , ``ssoEnabled``\ , ``predicates``\ , ``filters``. :paramtype routes: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayApiRoute] """ - super(GatewayRouteConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.app_resource_id = app_resource_id self.routes = routes @@ -4540,36 +4245,31 @@ class GatewayRouteConfigResource(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': 'GatewayRouteConfigProperties'}, + "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": "GatewayRouteConfigProperties"}, } - def __init__( - self, - *, - properties: Optional["GatewayRouteConfigProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.GatewayRouteConfigProperties"] = None, **kwargs): """ :keyword properties: API route config of the Spring Cloud Gateway. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigProperties """ - super(GatewayRouteConfigResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class GatewayRouteConfigResourceCollection(msrest.serialization.Model): +class GatewayRouteConfigResourceCollection(_serialization.Model): """Object that includes an array of Spring Cloud Gateway route config resources and a possible link for next set. :ivar value: Collection of Spring Cloud Gateway route config resources. @@ -4581,14 +4281,14 @@ class GatewayRouteConfigResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayRouteConfigResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GatewayRouteConfigResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["GatewayRouteConfigResource"]] = None, + value: Optional[List["_models.GatewayRouteConfigResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -4600,21 +4300,21 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(GatewayRouteConfigResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class GitPatternRepository(msrest.serialization.Model): +class GitPatternRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes """Git repository property payload for config server. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the repository. + :ivar name: Name of the repository. Required. :vartype name: str :ivar pattern: Collection of pattern of the repository. :vartype pattern: list[str] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -4635,22 +4335,22 @@ class GitPatternRepository(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'uri': {'required': True}, + "name": {"required": True}, + "uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'pattern': {'key': 'pattern', 'type': '[str]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "pattern": {"key": "pattern", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( @@ -4670,11 +4370,11 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of the repository. + :keyword name: Name of the repository. Required. :paramtype name: str :keyword pattern: Collection of pattern of the repository. :paramtype pattern: list[str] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -4693,7 +4393,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(GitPatternRepository, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.pattern = pattern self.uri = uri @@ -4707,7 +4407,7 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ImageRegistryCredential(msrest.serialization.Model): +class ImageRegistryCredential(_serialization.Model): """Credential of the image registry. :ivar username: The username of the image registry credential. @@ -4717,24 +4417,18 @@ class ImageRegistryCredential(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - username: Optional[str] = None, - password: Optional[str] = None, - **kwargs - ): + def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs): """ :keyword username: The username of the image registry credential. :paramtype username: str :keyword password: The password of the image registry credential. :paramtype password: str """ - super(ImageRegistryCredential, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.password = password @@ -4742,12 +4436,12 @@ def __init__( class UploadedUserSourceInfo(UserSourceInfo): """Source with uploaded location. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: JarUploadedUserSourceInfo, NetCoreZipUploadedUserSourceInfo, SourceUploadedUserSourceInfo. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + JarUploadedUserSourceInfo, NetCoreZipUploadedUserSourceInfo, SourceUploadedUserSourceInfo All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -4756,34 +4450,32 @@ class UploadedUserSourceInfo(UserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, } _subtype_map = { - 'type': {'Jar': 'JarUploadedUserSourceInfo', 'NetCoreZip': 'NetCoreZipUploadedUserSourceInfo', 'Source': 'SourceUploadedUserSourceInfo'} + "type": { + "Jar": "JarUploadedUserSourceInfo", + "NetCoreZip": "NetCoreZipUploadedUserSourceInfo", + "Source": "SourceUploadedUserSourceInfo", + } } - def __init__( - self, - *, - version: Optional[str] = None, - relative_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, version: Optional[str] = None, relative_path: Optional[str] = None, **kwargs): """ :keyword version: Version of the source. :paramtype version: str :keyword relative_path: Relative path of the storage which stores the source. :paramtype relative_path: str """ - super(UploadedUserSourceInfo, self).__init__(version=version, **kwargs) - self.type = 'UploadedUserSourceInfo' # type: str + super().__init__(version=version, **kwargs) + self.type = "UploadedUserSourceInfo" # type: str self.relative_path = relative_path @@ -4792,7 +4484,7 @@ class JarUploadedUserSourceInfo(UploadedUserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -4805,15 +4497,15 @@ class JarUploadedUserSourceInfo(UploadedUserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, - 'jvm_options': {'key': 'jvmOptions', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, + "jvm_options": {"key": "jvmOptions", "type": "str"}, } def __init__( @@ -4835,20 +4527,20 @@ def __init__( :keyword jvm_options: JVM parameter. :paramtype jvm_options: str """ - super(JarUploadedUserSourceInfo, self).__init__(version=version, relative_path=relative_path, **kwargs) - self.type = 'Jar' # type: str + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "Jar" # type: str self.runtime_version = runtime_version self.jvm_options = jvm_options -class KeyVaultCertificateProperties(CertificateProperties): +class KeyVaultCertificateProperties(CertificateProperties): # pylint: disable=too-many-instance-attributes """Properties of certificate imported from key vault. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -4864,9 +4556,9 @@ class KeyVaultCertificateProperties(CertificateProperties): :vartype subject_name: str :ivar dns_names: The domain list of certificate. :vartype dns_names: list[str] - :ivar vault_uri: Required. The vault uri of user key vault. + :ivar vault_uri: The vault uri of user key vault. Required. :vartype vault_uri: str - :ivar key_vault_cert_name: Required. The certificate name of key vault. + :ivar key_vault_cert_name: The certificate name of key vault. Required. :vartype key_vault_cert_name: str :ivar cert_version: The certificate version of key vault. :vartype cert_version: str @@ -4876,31 +4568,31 @@ class KeyVaultCertificateProperties(CertificateProperties): """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, - 'vault_uri': {'required': True}, - 'key_vault_cert_name': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, - 'vault_uri': {'key': 'vaultUri', 'type': 'str'}, - 'key_vault_cert_name': {'key': 'keyVaultCertName', 'type': 'str'}, - 'cert_version': {'key': 'certVersion', 'type': 'str'}, - 'exclude_private_key': {'key': 'excludePrivateKey', 'type': 'bool'}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, + "vault_uri": {"required": True}, + "key_vault_cert_name": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "vault_uri": {"key": "vaultUri", "type": "str"}, + "key_vault_cert_name": {"key": "keyVaultCertName", "type": "str"}, + "cert_version": {"key": "certVersion", "type": "str"}, + "exclude_private_key": {"key": "excludePrivateKey", "type": "bool"}, } def __init__( @@ -4909,13 +4601,13 @@ def __init__( vault_uri: str, key_vault_cert_name: str, cert_version: Optional[str] = None, - exclude_private_key: Optional[bool] = False, + exclude_private_key: bool = False, **kwargs ): """ - :keyword vault_uri: Required. The vault uri of user key vault. + :keyword vault_uri: The vault uri of user key vault. Required. :paramtype vault_uri: str - :keyword key_vault_cert_name: Required. The certificate name of key vault. + :keyword key_vault_cert_name: The certificate name of key vault. Required. :paramtype key_vault_cert_name: str :keyword cert_version: The certificate version of key vault. :paramtype cert_version: str @@ -4923,20 +4615,20 @@ def __init__( vault. :paramtype exclude_private_key: bool """ - super(KeyVaultCertificateProperties, self).__init__(**kwargs) - self.type = 'KeyVaultCertificate' # type: str + super().__init__(**kwargs) + self.type = "KeyVaultCertificate" # type: str self.vault_uri = vault_uri self.key_vault_cert_name = key_vault_cert_name self.cert_version = cert_version self.exclude_private_key = exclude_private_key -class LoadedCertificate(msrest.serialization.Model): +class LoadedCertificate(_serialization.Model): """Loaded certificate payload. All required parameters must be populated in order to send to Azure. - :ivar resource_id: Required. Resource Id of loaded certificate. + :ivar resource_id: Resource Id of loaded certificate. Required. :vartype resource_id: str :ivar load_trust_store: Indicate whether the certificate will be loaded into default trust store, only work for Java runtime. @@ -4944,65 +4636,54 @@ class LoadedCertificate(msrest.serialization.Model): """ _validation = { - 'resource_id': {'required': True}, + "resource_id": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'load_trust_store': {'key': 'loadTrustStore', 'type': 'bool'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "load_trust_store": {"key": "loadTrustStore", "type": "bool"}, } - def __init__( - self, - *, - resource_id: str, - load_trust_store: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, resource_id: str, load_trust_store: bool = False, **kwargs): """ - :keyword resource_id: Required. Resource Id of loaded certificate. + :keyword resource_id: Resource Id of loaded certificate. Required. :paramtype resource_id: str :keyword load_trust_store: Indicate whether the certificate will be loaded into default trust store, only work for Java runtime. :paramtype load_trust_store: bool """ - super(LoadedCertificate, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.load_trust_store = load_trust_store -class LogFileUrlResponse(msrest.serialization.Model): +class LogFileUrlResponse(_serialization.Model): """Log file URL payload. All required parameters must be populated in order to send to Azure. - :ivar url: Required. URL of the log file. + :ivar url: URL of the log file. Required. :vartype url: str """ _validation = { - 'url': {'required': True}, + "url": {"required": True}, } _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, } - def __init__( - self, - *, - url: str, - **kwargs - ): + def __init__(self, *, url: str, **kwargs): """ - :keyword url: Required. URL of the log file. + :keyword url: URL of the log file. Required. :paramtype url: str """ - super(LogFileUrlResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url -class LogSpecification(msrest.serialization.Model): +class LogSpecification(_serialization.Model): """Specifications of the Log for Azure Monitoring. :ivar name: Name of the log. @@ -5014,9 +4695,9 @@ class LogSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, } def __init__( @@ -5035,17 +4716,17 @@ def __init__( :keyword blob_duration: Blob duration of the log. :paramtype blob_duration: str """ - super(LogSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class ManagedIdentityProperties(msrest.serialization.Model): +class ManagedIdentityProperties(_serialization.Model): """Managed identity properties retrieved from ARM request headers. - :ivar type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.ManagedIdentityType :ivar principal_id: Principal Id. :vartype principal_id: str @@ -5054,35 +4735,35 @@ class ManagedIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ManagedIdentityType"]] = None, + type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs ): """ - :keyword type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.ManagedIdentityType :keyword principal_id: Principal Id. :paramtype principal_id: str :keyword tenant_id: Tenant Id. :paramtype tenant_id: str """ - super(ManagedIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.principal_id = principal_id self.tenant_id = tenant_id -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """Specifications of the Dimension of metrics. :ivar name: Name of the dimension. @@ -5095,9 +4776,9 @@ class MetricDimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -5117,13 +4798,13 @@ def __init__( export scenario. :paramtype to_be_exported_for_shoebox: bool """ - super(MetricDimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes """Specifications of the Metrics for Azure Monitoring. :ivar name: Name of the metric. @@ -5154,17 +4835,17 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "source_mdm_namespace": {"key": "sourceMdmNamespace", "type": "str"}, } def __init__( @@ -5179,7 +4860,7 @@ def __init__( supported_aggregation_types: Optional[List[str]] = None, supported_time_grain_types: Optional[List[str]] = None, fill_gap_with_zero: Optional[bool] = None, - dimensions: Optional[List["MetricDimension"]] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, source_mdm_namespace: Optional[str] = None, **kwargs ): @@ -5210,7 +4891,7 @@ def __init__( :keyword source_mdm_namespace: Name of the MDM namespace. Optional. :paramtype source_mdm_namespace: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -5224,13 +4905,13 @@ def __init__( self.source_mdm_namespace = source_mdm_namespace -class MonitoringSettingProperties(msrest.serialization.Model): +class MonitoringSettingProperties(_serialization.Model): """Monitoring Setting properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Monitoring Setting. Possible values include: - "NotAvailable", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the Monitoring Setting. Known values are: "NotAvailable", + "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingState :ivar error: Error when apply Monitoring Setting changes. @@ -5251,27 +4932,27 @@ class MonitoringSettingProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'app_insights_sampling_rate': {'maximum': 100, 'minimum': 0}, + "provisioning_state": {"readonly": True}, + "app_insights_sampling_rate": {"maximum": 100, "minimum": 0}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'trace_enabled': {'key': 'traceEnabled', 'type': 'bool'}, - 'app_insights_instrumentation_key': {'key': 'appInsightsInstrumentationKey', 'type': 'str'}, - 'app_insights_sampling_rate': {'key': 'appInsightsSamplingRate', 'type': 'float'}, - 'app_insights_agent_versions': {'key': 'appInsightsAgentVersions', 'type': 'ApplicationInsightsAgentVersions'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "trace_enabled": {"key": "traceEnabled", "type": "bool"}, + "app_insights_instrumentation_key": {"key": "appInsightsInstrumentationKey", "type": "str"}, + "app_insights_sampling_rate": {"key": "appInsightsSamplingRate", "type": "float"}, + "app_insights_agent_versions": {"key": "appInsightsAgentVersions", "type": "ApplicationInsightsAgentVersions"}, } def __init__( self, *, - error: Optional["Error"] = None, + error: Optional["_models.Error"] = None, trace_enabled: Optional[bool] = None, app_insights_instrumentation_key: Optional[str] = None, app_insights_sampling_rate: Optional[float] = None, - app_insights_agent_versions: Optional["ApplicationInsightsAgentVersions"] = None, + app_insights_agent_versions: Optional["_models.ApplicationInsightsAgentVersions"] = None, **kwargs ): """ @@ -5291,7 +4972,7 @@ def __init__( :paramtype app_insights_agent_versions: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApplicationInsightsAgentVersions """ - super(MonitoringSettingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.trace_enabled = trace_enabled @@ -5319,36 +5000,31 @@ class MonitoringSettingResource(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': 'MonitoringSettingProperties'}, + "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": "MonitoringSettingProperties"}, } - def __init__( - self, - *, - properties: Optional["MonitoringSettingProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.MonitoringSettingProperties"] = None, **kwargs): """ :keyword properties: Properties of the Monitoring Setting resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingProperties """ - super(MonitoringSettingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class NameAvailability(msrest.serialization.Model): +class NameAvailability(_serialization.Model): """Name availability result payload. :ivar name_available: Indicates whether the name is available. @@ -5360,9 +5036,9 @@ class NameAvailability(msrest.serialization.Model): """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } def __init__( @@ -5381,47 +5057,41 @@ def __init__( :keyword message: Message why the name is not available. :paramtype message: str """ - super(NameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class NameAvailabilityParameters(msrest.serialization.Model): +class NameAvailabilityParameters(_serialization.Model): """Name availability parameters payload. All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the resource to check name availability. + :ivar type: Type of the resource to check name availability. Required. :vartype type: str - :ivar name: Required. Name to be checked. + :ivar name: Name to be checked. Required. :vartype name: str """ _validation = { - 'type': {'required': True}, - 'name': {'required': True}, + "type": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - type: str, - name: str, - **kwargs - ): + def __init__(self, *, type: str, name: str, **kwargs): """ - :keyword type: Required. Type of the resource to check name availability. + :keyword type: Type of the resource to check name availability. Required. :paramtype type: str - :keyword name: Required. Name to be checked. + :keyword name: Name to be checked. Required. :paramtype name: str """ - super(NameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name @@ -5431,7 +5101,7 @@ class NetCoreZipUploadedUserSourceInfo(UploadedUserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -5444,15 +5114,15 @@ class NetCoreZipUploadedUserSourceInfo(UploadedUserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'net_core_main_entry_path': {'key': 'netCoreMainEntryPath', 'type': 'str'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "net_core_main_entry_path": {"key": "netCoreMainEntryPath", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, } def __init__( @@ -5474,13 +5144,13 @@ def __init__( :keyword runtime_version: Runtime version of the .Net file. :paramtype runtime_version: str """ - super(NetCoreZipUploadedUserSourceInfo, self).__init__(version=version, relative_path=relative_path, **kwargs) - self.type = 'NetCoreZip' # type: str + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "NetCoreZip" # type: str self.net_core_main_entry_path = net_core_main_entry_path self.runtime_version = runtime_version -class NetworkProfile(msrest.serialization.Model): +class NetworkProfile(_serialization.Model): """Service network profile payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -5507,18 +5177,18 @@ class NetworkProfile(msrest.serialization.Model): """ _validation = { - 'outbound_i_ps': {'readonly': True}, - 'required_traffics': {'readonly': True}, + "outbound_i_ps": {"readonly": True}, + "required_traffics": {"readonly": True}, } _attribute_map = { - 'service_runtime_subnet_id': {'key': 'serviceRuntimeSubnetId', 'type': 'str'}, - 'app_subnet_id': {'key': 'appSubnetId', 'type': 'str'}, - 'service_cidr': {'key': 'serviceCidr', 'type': 'str'}, - 'service_runtime_network_resource_group': {'key': 'serviceRuntimeNetworkResourceGroup', 'type': 'str'}, - 'app_network_resource_group': {'key': 'appNetworkResourceGroup', 'type': 'str'}, - 'outbound_i_ps': {'key': 'outboundIPs', 'type': 'NetworkProfileOutboundIPs'}, - 'required_traffics': {'key': 'requiredTraffics', 'type': '[RequiredTraffic]'}, + "service_runtime_subnet_id": {"key": "serviceRuntimeSubnetId", "type": "str"}, + "app_subnet_id": {"key": "appSubnetId", "type": "str"}, + "service_cidr": {"key": "serviceCidr", "type": "str"}, + "service_runtime_network_resource_group": {"key": "serviceRuntimeNetworkResourceGroup", "type": "str"}, + "app_network_resource_group": {"key": "appNetworkResourceGroup", "type": "str"}, + "outbound_i_ps": {"key": "outboundIPs", "type": "NetworkProfileOutboundIPs"}, + "required_traffics": {"key": "requiredTraffics", "type": "[RequiredTraffic]"}, } def __init__( @@ -5547,7 +5217,7 @@ def __init__( Azure Spring Cloud Apps. :paramtype app_network_resource_group: str """ - super(NetworkProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_runtime_subnet_id = service_runtime_subnet_id self.app_subnet_id = app_subnet_id self.service_cidr = service_cidr @@ -5557,7 +5227,7 @@ def __init__( self.required_traffics = None -class NetworkProfileOutboundIPs(msrest.serialization.Model): +class NetworkProfileOutboundIPs(_serialization.Model): """Desired outbound IP resources for Azure Spring Cloud instance. Variables are only populated by the server, and will be ignored when sending a request. @@ -5567,24 +5237,20 @@ class NetworkProfileOutboundIPs(msrest.serialization.Model): """ _validation = { - 'public_i_ps': {'readonly': True}, + "public_i_ps": {"readonly": True}, } _attribute_map = { - 'public_i_ps': {'key': 'publicIPs', 'type': '[str]'}, + "public_i_ps": {"key": "publicIPs", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(NetworkProfileOutboundIPs, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.public_i_ps = None -class OperationDetail(msrest.serialization.Model): +class OperationDetail(_serialization.Model): """Operation detail payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -5596,7 +5262,7 @@ class OperationDetail(msrest.serialization.Model): :ivar display: Display of the operation. :vartype display: ~azure.mgmt.appplatform.v2022_01_01_preview.models.OperationDisplay :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. Possible values include: "Internal". + internal only APIs. "Internal" :vartype action_type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.ActionType :ivar origin: Origin of the operation. :vartype origin: str @@ -5605,16 +5271,16 @@ class OperationDetail(msrest.serialization.Model): """ _validation = { - 'action_type': {'readonly': True}, + "action_type": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'action_type': {'key': 'actionType', 'type': 'str'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "action_type": {"key": "actionType", "type": "str"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "OperationProperties"}, } def __init__( @@ -5622,9 +5288,9 @@ 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, - properties: Optional["OperationProperties"] = None, + properties: Optional["_models.OperationProperties"] = None, **kwargs ): """ @@ -5639,7 +5305,7 @@ def __init__( :keyword properties: Properties of the operation. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.OperationProperties """ - super(OperationDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display @@ -5648,7 +5314,7 @@ def __init__( self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display payload. :ivar provider: Resource provider of the operation. @@ -5662,10 +5328,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__( @@ -5687,14 +5353,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 OperationProperties(msrest.serialization.Model): +class OperationProperties(_serialization.Model): """Extra Operation properties. :ivar service_specification: Service specifications of the operation. @@ -5703,25 +5369,20 @@ class OperationProperties(msrest.serialization.Model): """ _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, } - def __init__( - self, - *, - service_specification: Optional["ServiceSpecification"] = None, - **kwargs - ): + def __init__(self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs): """ :keyword service_specification: Service specifications of the operation. :paramtype service_specification: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceSpecification """ - super(OperationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_specification = service_specification -class PersistentDisk(msrest.serialization.Model): +class PersistentDisk(_serialization.Model): """Persistent disk payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -5735,69 +5396,56 @@ class PersistentDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 50, 'minimum': 0}, - 'used_in_gb': {'readonly': True, 'maximum': 50, 'minimum': 0}, + "size_in_gb": {"maximum": 50, "minimum": 0}, + "used_in_gb": {"readonly": True, "maximum": 50, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'used_in_gb': {'key': 'usedInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "used_in_gb": {"key": "usedInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: Optional[str] = None, **kwargs): """ :keyword size_in_gb: Size of the persistent disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the persistent disk. :paramtype mount_path: str """ - super(PersistentDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.used_in_gb = None self.mount_path = mount_path -class RegenerateTestKeyRequestPayload(msrest.serialization.Model): +class RegenerateTestKeyRequestPayload(_serialization.Model): """Regenerate test key request payload. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :ivar key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :vartype key_type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.TestKeyType """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "TestKeyType"], - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.TestKeyType"], **kwargs): """ - :keyword key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :keyword key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :paramtype key_type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.TestKeyType """ - super(RegenerateTestKeyRequestPayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type -class RequiredTraffic(msrest.serialization.Model): +class RequiredTraffic(_serialization.Model): """Required inbound or outbound traffic for Azure Spring Cloud instance. Variables are only populated by the server, and will be ignored when sending a request. @@ -5810,34 +5458,29 @@ class RequiredTraffic(msrest.serialization.Model): :vartype ips: list[str] :ivar fqdns: The FQDN list of required traffic. :vartype fqdns: list[str] - :ivar direction: The direction of required traffic. Possible values include: "Inbound", - "Outbound". + :ivar direction: The direction of required traffic. Known values are: "Inbound" and "Outbound". :vartype direction: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.TrafficDirection """ _validation = { - 'protocol': {'readonly': True}, - 'port': {'readonly': True}, - 'ips': {'readonly': True}, - 'fqdns': {'readonly': True}, - 'direction': {'readonly': True}, + "protocol": {"readonly": True}, + "port": {"readonly": True}, + "ips": {"readonly": True}, + "fqdns": {"readonly": True}, + "direction": {"readonly": True}, } _attribute_map = { - 'protocol': {'key': 'protocol', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - 'ips': {'key': 'ips', 'type': '[str]'}, - 'fqdns': {'key': 'fqdns', 'type': '[str]'}, - 'direction': {'key': 'direction', 'type': 'str'}, + "protocol": {"key": "protocol", "type": "str"}, + "port": {"key": "port", "type": "int"}, + "ips": {"key": "ips", "type": "[str]"}, + "fqdns": {"key": "fqdns", "type": "[str]"}, + "direction": {"key": "direction", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RequiredTraffic, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.protocol = None self.port = None self.ips = None @@ -5845,7 +5488,7 @@ def __init__( self.direction = None -class ResourceRequests(msrest.serialization.Model): +class ResourceRequests(_serialization.Model): """Deployment resource request payload. :ivar cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 for @@ -5857,17 +5500,11 @@ class ResourceRequests(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - *, - cpu: Optional[str] = None, - memory: Optional[str] = None, - **kwargs - ): + def __init__(self, *, cpu: Optional[str] = None, memory: Optional[str] = None, **kwargs): """ :keyword cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 for Basic tier, and {500m, 1, 2, 3, 4} for Standard tier. @@ -5876,12 +5513,12 @@ def __init__( {512Mi, 1Gi, 2Gi} for Basic tier, and {512Mi, 1Gi, 2Gi, ..., 8Gi} for Standard tier. :paramtype memory: str """ - super(ResourceRequests, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory = memory -class ResourceSku(msrest.serialization.Model): +class ResourceSku(_serialization.Model): """Describes an available Azure Spring Cloud SKU. :ivar resource_type: Gets the type of resource the SKU applies to. @@ -5905,13 +5542,13 @@ class ResourceSku(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'SkuCapacity'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[ResourceSkuLocationInfo]'}, - 'restrictions': {'key': 'restrictions', 'type': '[ResourceSkuRestrictions]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "SkuCapacity"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[ResourceSkuLocationInfo]"}, + "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, } def __init__( @@ -5920,10 +5557,10 @@ def __init__( resource_type: Optional[str] = None, name: Optional[str] = None, tier: Optional[str] = None, - capacity: Optional["SkuCapacity"] = None, + capacity: Optional["_models.SkuCapacity"] = None, locations: Optional[List[str]] = None, - location_info: Optional[List["ResourceSkuLocationInfo"]] = None, - restrictions: Optional[List["ResourceSkuRestrictions"]] = None, + location_info: Optional[List["_models.ResourceSkuLocationInfo"]] = None, + restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None, **kwargs ): """ @@ -5946,7 +5583,7 @@ def __init__( :paramtype restrictions: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceSkuRestrictions] """ - super(ResourceSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.name = name self.tier = tier @@ -5956,7 +5593,7 @@ def __init__( self.restrictions = restrictions -class ResourceSkuCapabilities(msrest.serialization.Model): +class ResourceSkuCapabilities(_serialization.Model): """ResourceSkuCapabilities. :ivar name: Gets an invariant to describe the feature. @@ -5966,29 +5603,23 @@ class ResourceSkuCapabilities(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: Gets an invariant to describe the feature. :paramtype name: str :keyword value: Gets an invariant if the feature is measured by quantity. :paramtype value: str """ - super(ResourceSkuCapabilities, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class ResourceSkuCollection(msrest.serialization.Model): +class ResourceSkuCollection(_serialization.Model): """Object that includes an array of Azure Spring Cloud SKU and a possible link for next set. :ivar value: Collection of resource SKU. @@ -5999,16 +5630,12 @@ class ResourceSkuCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ResourceSku"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ResourceSku"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of resource SKU. @@ -6017,12 +5644,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ResourceSkuCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ResourceSkuLocationInfo(msrest.serialization.Model): +class ResourceSkuLocationInfo(_serialization.Model): """Locations and availability zones where the SKU is available. :ivar location: Gets location of the SKU. @@ -6035,9 +5662,9 @@ class ResourceSkuLocationInfo(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'zone_details': {'key': 'zoneDetails', 'type': '[ResourceSkuZoneDetails]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "zone_details": {"key": "zoneDetails", "type": "[ResourceSkuZoneDetails]"}, } def __init__( @@ -6045,7 +5672,7 @@ def __init__( *, location: Optional[str] = None, zones: Optional[List[str]] = None, - zone_details: Optional[List["ResourceSkuZoneDetails"]] = None, + zone_details: Optional[List["_models.ResourceSkuZoneDetails"]] = None, **kwargs ): """ @@ -6057,13 +5684,13 @@ def __init__( :paramtype zone_details: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceSkuZoneDetails] """ - super(ResourceSkuLocationInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones self.zone_details = zone_details -class ResourceSkuRestrictionInfo(msrest.serialization.Model): +class ResourceSkuRestrictionInfo(_serialization.Model): """Information about the restriction where the SKU cannot be used. :ivar locations: Gets locations where the SKU is restricted. @@ -6073,33 +5700,27 @@ class ResourceSkuRestrictionInfo(msrest.serialization.Model): """ _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - locations: Optional[List[str]] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, locations: Optional[List[str]] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword locations: Gets locations where the SKU is restricted. :paramtype locations: list[str] :keyword zones: Gets list of availability zones where the SKU is restricted. :paramtype zones: list[str] """ - super(ResourceSkuRestrictionInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.locations = locations self.zones = zones -class ResourceSkuRestrictions(msrest.serialization.Model): +class ResourceSkuRestrictions(_serialization.Model): """Restrictions where the SKU cannot be used. - :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. Known + values are: "Location" and "Zone". :vartype type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceSkuRestrictionsType :ivar values: Gets the value of restrictions. If the restriction type is set to @@ -6110,31 +5731,30 @@ class ResourceSkuRestrictions(msrest.serialization.Model): :vartype restriction_info: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceSkuRestrictionInfo :ivar reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceSkuRestrictionsReasonCode """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'ResourceSkuRestrictionInfo'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "restriction_info": {"key": "restrictionInfo", "type": "ResourceSkuRestrictionInfo"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceSkuRestrictionsType"]] = None, + type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None, values: Optional[List[str]] = None, - restriction_info: Optional["ResourceSkuRestrictionInfo"] = None, - reason_code: Optional[Union[str, "ResourceSkuRestrictionsReasonCode"]] = None, + restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None, + reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None, **kwargs ): """ :keyword type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + Known values are: "Location" and "Zone". :paramtype type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceSkuRestrictionsType :keyword values: Gets the value of restrictions. If the restriction type is set to @@ -6145,19 +5765,18 @@ def __init__( :paramtype restriction_info: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceSkuRestrictionInfo :keyword reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceSkuRestrictionsReasonCode """ - super(ResourceSkuRestrictions, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.values = values self.restriction_info = restriction_info self.reason_code = reason_code -class ResourceSkuZoneDetails(msrest.serialization.Model): +class ResourceSkuZoneDetails(_serialization.Model): """Details of capabilities available to a SKU in specific zones. :ivar name: Gets the set of zones that the SKU is available in with the @@ -6170,15 +5789,15 @@ class ResourceSkuZoneDetails(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[ResourceSkuCapabilities]'}, + "name": {"key": "name", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, } def __init__( self, *, name: Optional[List[str]] = None, - capabilities: Optional[List["ResourceSkuCapabilities"]] = None, + capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None, **kwargs ): """ @@ -6190,12 +5809,12 @@ def __init__( :paramtype capabilities: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceSkuCapabilities] """ - super(ResourceSkuZoneDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.capabilities = capabilities -class ResourceUploadDefinition(msrest.serialization.Model): +class ResourceUploadDefinition(_serialization.Model): """Resource upload definition payload. :ivar relative_path: Source relative path. @@ -6205,29 +5824,23 @@ class ResourceUploadDefinition(msrest.serialization.Model): """ _attribute_map = { - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'upload_url': {'key': 'uploadUrl', 'type': 'str'}, + "relative_path": {"key": "relativePath", "type": "str"}, + "upload_url": {"key": "uploadUrl", "type": "str"}, } - def __init__( - self, - *, - relative_path: Optional[str] = None, - upload_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, relative_path: Optional[str] = None, upload_url: Optional[str] = None, **kwargs): """ :keyword relative_path: Source relative path. :paramtype relative_path: str :keyword upload_url: Upload URL. :paramtype upload_url: str """ - super(ResourceUploadDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.relative_path = relative_path self.upload_url = upload_url -class ServiceRegistryInstance(msrest.serialization.Model): +class ServiceRegistryInstance(_serialization.Model): """Collection of instances belong to the Service Registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -6239,33 +5852,29 @@ class ServiceRegistryInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServiceRegistryInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class ServiceRegistryProperties(msrest.serialization.Model): +class ServiceRegistryProperties(_serialization.Model): """Service Registry properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Service Registry. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Service Registry. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceRegistryProvisioningState :ivar resource_requests: The requested resource quantity for required CPU and Memory. @@ -6277,24 +5886,20 @@ class ServiceRegistryProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'resource_requests': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'ServiceRegistryResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[ServiceRegistryInstance]'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "ServiceRegistryResourceRequests"}, + "instances": {"key": "instances", "type": "[ServiceRegistryInstance]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServiceRegistryProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.resource_requests = None self.instances = None @@ -6319,36 +5924,31 @@ class ServiceRegistryResource(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': 'ServiceRegistryProperties'}, + "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": "ServiceRegistryProperties"}, } - def __init__( - self, - *, - properties: Optional["ServiceRegistryProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ServiceRegistryProperties"] = None, **kwargs): """ :keyword properties: Service Registry properties payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceRegistryProperties """ - super(ServiceRegistryResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ServiceRegistryResourceCollection(msrest.serialization.Model): +class ServiceRegistryResourceCollection(_serialization.Model): """Object that includes an array of Service Registry resources and a possible link for next set. :ivar value: Collection of Service Registry resources. @@ -6360,14 +5960,14 @@ class ServiceRegistryResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceRegistryResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServiceRegistryResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ServiceRegistryResource"]] = None, + value: Optional[List["_models.ServiceRegistryResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -6379,12 +5979,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ServiceRegistryResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServiceRegistryResourceRequests(msrest.serialization.Model): +class ServiceRegistryResourceRequests(_serialization.Model): """Resource request payload of Service Registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -6398,24 +5998,20 @@ class ServiceRegistryResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, - 'instance_count': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServiceRegistryResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None self.instance_count = None @@ -6436,42 +6032,35 @@ class TrackedResource(Resource): :vartype system_data: ~azure.mgmt.appplatform.v2022_01_01_preview.models.SystemData :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] """ _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -6491,8 +6080,7 @@ class ServiceResource(TrackedResource): :vartype system_data: ~azure.mgmt.appplatform.v2022_01_01_preview.models.SystemData :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] :ivar properties: Properties of the Service resource. :vartype properties: @@ -6502,21 +6090,21 @@ class ServiceResource(TrackedResource): """ _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ClusterResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "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"}, + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "ClusterResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( @@ -6524,15 +6112,15 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - properties: Optional["ClusterResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.ClusterResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] :keyword properties: Properties of the Service resource. :paramtype properties: @@ -6540,12 +6128,12 @@ def __init__( :keyword sku: Sku of the Service resource. :paramtype sku: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Sku """ - super(ServiceResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.properties = properties self.sku = sku -class ServiceResourceList(msrest.serialization.Model): +class ServiceResourceList(_serialization.Model): """Object that includes an array of Service resources and a possible link for next set. :ivar value: Collection of Service resources. @@ -6556,16 +6144,12 @@ class ServiceResourceList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ServiceResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ServiceResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Service resources. @@ -6574,12 +6158,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ServiceResourceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification payload. :ivar log_specifications: Specifications of the Log for Azure Monitoring. @@ -6591,15 +6175,15 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } def __init__( self, *, - log_specifications: Optional[List["LogSpecification"]] = None, - metric_specifications: Optional[List["MetricSpecification"]] = None, + log_specifications: Optional[List["_models.LogSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -6610,12 +6194,12 @@ def __init__( :paramtype metric_specifications: list[~azure.mgmt.appplatform.v2022_01_01_preview.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_specifications = log_specifications self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """Sku of Azure Spring Cloud. :ivar name: Name of the Sku. @@ -6627,19 +6211,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Optional[str] = "S0", - tier: Optional[str] = "Standard", - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: str = "S0", tier: str = "Standard", capacity: Optional[int] = None, **kwargs): """ :keyword name: Name of the Sku. :paramtype name: str @@ -6648,37 +6225,37 @@ def __init__( :keyword capacity: Current capacity of the target resource. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SkuCapacity(msrest.serialization.Model): +class SkuCapacity(_serialization.Model): """The SKU capacity. All required parameters must be populated in order to send to Azure. - :ivar minimum: Required. Gets or sets the minimum. + :ivar minimum: Gets or sets the minimum. Required. :vartype minimum: int :ivar maximum: Gets or sets the maximum. :vartype maximum: int :ivar default: Gets or sets the default. :vartype default: int - :ivar scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :ivar scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", and + "Automatic". :vartype scale_type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.SkuScaleType """ _validation = { - 'minimum': {'required': True}, + "minimum": {"required": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } def __init__( @@ -6687,21 +6264,21 @@ def __init__( minimum: int, maximum: Optional[int] = None, default: Optional[int] = None, - scale_type: Optional[Union[str, "SkuScaleType"]] = None, + scale_type: Optional[Union[str, "_models.SkuScaleType"]] = None, **kwargs ): """ - :keyword minimum: Required. Gets or sets the minimum. + :keyword minimum: Gets or sets the minimum. Required. :paramtype minimum: int :keyword maximum: Gets or sets the maximum. :paramtype maximum: int :keyword default: Gets or sets the default. :paramtype default: int - :keyword scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :keyword scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", + and "Automatic". :paramtype scale_type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.SkuScaleType """ - super(SkuCapacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.minimum = minimum self.maximum = maximum self.default = default @@ -6713,7 +6290,7 @@ class SourceUploadedUserSourceInfo(UploadedUserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -6728,15 +6305,15 @@ class SourceUploadedUserSourceInfo(UploadedUserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'artifact_selector': {'key': 'artifactSelector', 'type': 'str'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "artifact_selector": {"key": "artifactSelector", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, } def __init__( @@ -6760,13 +6337,13 @@ def __init__( :keyword runtime_version: Runtime version of the source file. :paramtype runtime_version: str """ - super(SourceUploadedUserSourceInfo, self).__init__(version=version, relative_path=relative_path, **kwargs) - self.type = 'Source' # type: str + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "Source" # type: str self.artifact_selector = artifact_selector self.runtime_version = runtime_version -class SsoProperties(msrest.serialization.Model): +class SsoProperties(_serialization.Model): """Single sign-on related configuration. :ivar scope: It defines the specific actions applications can be allowed to do on a user's @@ -6781,10 +6358,10 @@ class SsoProperties(msrest.serialization.Model): """ _attribute_map = { - 'scope': {'key': 'scope', 'type': '[str]'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'client_secret': {'key': 'clientSecret', 'type': 'str'}, - 'issuer_uri': {'key': 'issuerUri', 'type': 'str'}, + "scope": {"key": "scope", "type": "[str]"}, + "client_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, + "issuer_uri": {"key": "issuerUri", "type": "str"}, } def __init__( @@ -6807,14 +6384,14 @@ def __init__( :keyword issuer_uri: The URI of Issuer Identifier. :paramtype issuer_uri: str """ - super(SsoProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.scope = scope self.client_id = client_id self.client_secret = client_secret self.issuer_uri = issuer_uri -class StackProperties(msrest.serialization.Model): +class StackProperties(_serialization.Model): """KPack ClusterStack properties payload. :ivar id: Id of the ClusterStack. @@ -6824,16 +6401,12 @@ class StackProperties(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( - self, - *, - id: Optional[str] = None, - version: Optional[str] = None, - **kwargs + self, *, id: Optional[str] = None, version: Optional[str] = None, **kwargs # pylint: disable=redefined-builtin ): """ :keyword id: Id of the ClusterStack. @@ -6841,43 +6414,36 @@ def __init__( :keyword version: Version of the ClusterStack. :paramtype version: str """ - super(StackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.version = version -class StorageProperties(msrest.serialization.Model): +class StorageProperties(_serialization.Model): """Storage resource payload. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: StorageAccount. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + StorageAccount All required parameters must be populated in order to send to Azure. - :ivar storage_type: Required. The type of the storage.Constant filled by server. Possible - values include: "StorageAccount". + :ivar storage_type: The type of the storage. Required. "StorageAccount" :vartype storage_type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageType """ _validation = { - 'storage_type': {'required': True}, + "storage_type": {"required": True}, } _attribute_map = { - 'storage_type': {'key': 'storageType', 'type': 'str'}, + "storage_type": {"key": "storageType", "type": "str"}, } - _subtype_map = { - 'storage_type': {'StorageAccount': 'StorageAccount'} - } + _subtype_map = {"storage_type": {"StorageAccount": "StorageAccount"}} - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.storage_type = None # type: Optional[str] @@ -6886,42 +6452,35 @@ class StorageAccount(StorageProperties): All required parameters must be populated in order to send to Azure. - :ivar storage_type: Required. The type of the storage.Constant filled by server. Possible - values include: "StorageAccount". + :ivar storage_type: The type of the storage. Required. "StorageAccount" :vartype storage_type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageType - :ivar account_name: Required. The account name of the Azure Storage Account. + :ivar account_name: The account name of the Azure Storage Account. Required. :vartype account_name: str - :ivar account_key: Required. The account key of the Azure Storage Account. + :ivar account_key: The account key of the Azure Storage Account. Required. :vartype account_key: str """ _validation = { - 'storage_type': {'required': True}, - 'account_name': {'required': True}, - 'account_key': {'required': True}, + "storage_type": {"required": True}, + "account_name": {"required": True}, + "account_key": {"required": True}, } _attribute_map = { - 'storage_type': {'key': 'storageType', 'type': 'str'}, - 'account_name': {'key': 'accountName', 'type': 'str'}, - 'account_key': {'key': 'accountKey', 'type': 'str'}, + "storage_type": {"key": "storageType", "type": "str"}, + "account_name": {"key": "accountName", "type": "str"}, + "account_key": {"key": "accountKey", "type": "str"}, } - def __init__( - self, - *, - account_name: str, - account_key: str, - **kwargs - ): + def __init__(self, *, account_name: str, account_key: str, **kwargs): """ - :keyword account_name: Required. The account name of the Azure Storage Account. + :keyword account_name: The account name of the Azure Storage Account. Required. :paramtype account_name: str - :keyword account_key: Required. The account key of the Azure Storage Account. + :keyword account_key: The account key of the Azure Storage Account. Required. :paramtype account_key: str """ - super(StorageAccount, self).__init__(**kwargs) - self.storage_type = 'StorageAccount' # type: str + super().__init__(**kwargs) + self.storage_type = "StorageAccount" # type: str self.account_name = account_name self.account_key = account_key @@ -6944,35 +6503,30 @@ class StorageResource(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': 'StorageProperties'}, + "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": "StorageProperties"}, } - def __init__( - self, - *, - properties: Optional["StorageProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.StorageProperties"] = None, **kwargs): """ :keyword properties: Properties of the storage resource payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageProperties """ - super(StorageResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class StorageResourceCollection(msrest.serialization.Model): +class StorageResourceCollection(_serialization.Model): """Collection compose of storage resources list and a possible link for next page. :ivar value: The storage resources list. @@ -6982,16 +6536,12 @@ class StorageResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["StorageResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.StorageResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The storage resources list. @@ -6999,7 +6549,7 @@ def __init__( :keyword next_link: The link to next page of storage list. :paramtype next_link: str """ - super(StorageResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -7023,36 +6573,31 @@ class SupportedBuildpackResource(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': 'SupportedBuildpackResourceProperties'}, + "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": "SupportedBuildpackResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["SupportedBuildpackResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.SupportedBuildpackResourceProperties"] = None, **kwargs): """ :keyword properties: Supported buildpack resource properties. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.SupportedBuildpackResourceProperties """ - super(SupportedBuildpackResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class SupportedBuildpackResourceProperties(msrest.serialization.Model): +class SupportedBuildpackResourceProperties(_serialization.Model): """Supported buildpack resource properties. :ivar buildpack_id: The id of supported buildpack. @@ -7060,24 +6605,19 @@ class SupportedBuildpackResourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'buildpack_id': {'key': 'buildpackId', 'type': 'str'}, + "buildpack_id": {"key": "buildpackId", "type": "str"}, } - def __init__( - self, - *, - buildpack_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, buildpack_id: Optional[str] = None, **kwargs): """ :keyword buildpack_id: The id of supported buildpack. :paramtype buildpack_id: str """ - super(SupportedBuildpackResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.buildpack_id = buildpack_id -class SupportedBuildpacksCollection(msrest.serialization.Model): +class SupportedBuildpacksCollection(_serialization.Model): """Object that includes an array of supported buildpacks resources and a possible link for next set. :ivar value: Collection of supported buildpacks resources. @@ -7089,14 +6629,14 @@ class SupportedBuildpacksCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedBuildpackResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SupportedBuildpackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["SupportedBuildpackResource"]] = None, + value: Optional[List["_models.SupportedBuildpackResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -7108,19 +6648,19 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(SupportedBuildpacksCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SupportedRuntimeVersion(msrest.serialization.Model): +class SupportedRuntimeVersion(_serialization.Model): """Supported deployment runtime version descriptor. - :ivar value: The raw value which could be passed to deployment CRUD operations. Possible values - include: "Java_8", "Java_11", "Java_17", "NetCore_31". + :ivar value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", "Java_17", and "NetCore_31". :vartype value: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.SupportedRuntimeValue - :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). Known + values are: "Java" and ".NET Core". :vartype platform: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.SupportedRuntimePlatform :ivar version: The detailed version (major.minor) of the platform. @@ -7128,32 +6668,32 @@ class SupportedRuntimeVersion(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'platform': {'key': 'platform', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "platform": {"key": "platform", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - value: Optional[Union[str, "SupportedRuntimeValue"]] = None, - platform: Optional[Union[str, "SupportedRuntimePlatform"]] = None, + value: Optional[Union[str, "_models.SupportedRuntimeValue"]] = None, + platform: Optional[Union[str, "_models.SupportedRuntimePlatform"]] = None, version: Optional[str] = None, **kwargs ): """ - :keyword value: The raw value which could be passed to deployment CRUD operations. Possible - values include: "Java_8", "Java_11", "Java_17", "NetCore_31". + :keyword value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", "Java_17", and "NetCore_31". :paramtype value: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.SupportedRuntimeValue :keyword platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + Known values are: "Java" and ".NET Core". :paramtype platform: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.SupportedRuntimePlatform :keyword version: The detailed version (major.minor) of the platform. :paramtype version: str """ - super(SupportedRuntimeVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.platform = platform self.version = version @@ -7178,36 +6718,31 @@ class SupportedStackResource(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': 'SupportedStackResourceProperties'}, + "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": "SupportedStackResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["SupportedStackResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.SupportedStackResourceProperties"] = None, **kwargs): """ :keyword properties: Supported stack resource properties. :paramtype properties: ~azure.mgmt.appplatform.v2022_01_01_preview.models.SupportedStackResourceProperties """ - super(SupportedStackResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class SupportedStackResourceProperties(msrest.serialization.Model): +class SupportedStackResourceProperties(_serialization.Model): """Supported stack resource properties. :ivar stack_id: The id of supported stack. @@ -7217,29 +6752,23 @@ class SupportedStackResourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'stack_id': {'key': 'stackId', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "stack_id": {"key": "stackId", "type": "str"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - *, - stack_id: Optional[str] = None, - version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, stack_id: Optional[str] = None, version: Optional[str] = None, **kwargs): """ :keyword stack_id: The id of supported stack. :paramtype stack_id: str :keyword version: The version of supported stack. :paramtype version: str """ - super(SupportedStackResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.stack_id = stack_id self.version = version -class SupportedStacksCollection(msrest.serialization.Model): +class SupportedStacksCollection(_serialization.Model): """Object that includes an array of supported stacks resources and a possible link for next set. :ivar value: Collection of supported stacks resources. @@ -7250,14 +6779,14 @@ class SupportedStacksCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedStackResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SupportedStackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["SupportedStackResource"]] = None, + value: Optional[List["_models.SupportedStackResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -7269,26 +6798,26 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(SupportedStacksCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -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.appplatform.v2022_01_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. 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.appplatform.v2022_01_01_preview.models.LastModifiedByType :ivar last_modified_at: The timestamp of resource modification (UTC). @@ -7296,44 +6825,44 @@ class SystemData(msrest.serialization.Model): """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "LastModifiedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.appplatform.v2022_01_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. 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.appplatform.v2022_01_01_preview.models.LastModifiedByType :keyword last_modified_at: The timestamp of resource modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -7342,7 +6871,7 @@ def __init__( self.last_modified_at = last_modified_at -class TemporaryDisk(msrest.serialization.Model): +class TemporaryDisk(_serialization.Model): """Temporary disk payload. :ivar size_in_gb: Size of the temporary disk in GB. @@ -7352,33 +6881,27 @@ class TemporaryDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 5, 'minimum': 0}, + "size_in_gb": {"maximum": 5, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = "/tmp", - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: str = "/tmp", **kwargs): """ :keyword size_in_gb: Size of the temporary disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the temporary disk. :paramtype mount_path: str """ - super(TemporaryDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.mount_path = mount_path -class TestKeys(msrest.serialization.Model): +class TestKeys(_serialization.Model): """Test keys payload. :ivar primary_key: Primary key. @@ -7394,11 +6917,11 @@ class TestKeys(msrest.serialization.Model): """ _attribute_map = { - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'primary_test_endpoint': {'key': 'primaryTestEndpoint', 'type': 'str'}, - 'secondary_test_endpoint': {'key': 'secondaryTestEndpoint', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "primary_test_endpoint": {"key": "primaryTestEndpoint", "type": "str"}, + "secondary_test_endpoint": {"key": "secondaryTestEndpoint", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, } def __init__( @@ -7423,7 +6946,7 @@ def __init__( :keyword enabled: Indicates whether the test endpoint feature enabled or not. :paramtype enabled: bool """ - super(TestKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_key = primary_key self.secondary_key = secondary_key self.primary_test_endpoint = primary_test_endpoint @@ -7431,7 +6954,7 @@ def __init__( self.enabled = enabled -class TriggeredBuildResult(msrest.serialization.Model): +class TriggeredBuildResult(_serialization.Model): """The build result triggered by a build. :ivar id: The unique build id of this build result. @@ -7439,24 +6962,19 @@ class TriggeredBuildResult(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The unique build id of this build result. :paramtype id: str """ - super(TriggeredBuildResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class ValidationMessages(msrest.serialization.Model): +class ValidationMessages(_serialization.Model): """Validate messages of the configuration service git repositories. :ivar name: The name of the configuration service git repository. @@ -7466,23 +6984,17 @@ class ValidationMessages(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'messages': {'key': 'messages', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - messages: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs): """ :keyword name: The name of the configuration service git repository. :paramtype name: str :keyword messages: Detailed validation messages. :paramtype messages: list[str] """ - super(ValidationMessages, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.messages = messages diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/__init__.py index 0da100b4246c..57694a8d82f6 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/__init__.py @@ -30,28 +30,34 @@ from ._api_portals_operations import ApiPortalsOperations from ._api_portal_custom_domains_operations import ApiPortalCustomDomainsOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'ConfigurationServicesOperations', - 'ServiceRegistriesOperations', - 'BuildServiceOperations', - 'BuildpackBindingOperations', - 'BuildServiceBuilderOperations', - 'BuildServiceAgentPoolOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'StoragesOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', - 'GatewaysOperations', - 'GatewayRouteConfigsOperations', - 'GatewayCustomDomainsOperations', - 'ApiPortalsOperations', - 'ApiPortalCustomDomainsOperations', + "ServicesOperations", + "ConfigServersOperations", + "ConfigurationServicesOperations", + "ServiceRegistriesOperations", + "BuildServiceOperations", + "BuildpackBindingOperations", + "BuildServiceBuilderOperations", + "BuildServiceAgentPoolOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "StoragesOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", + "GatewaysOperations", + "GatewayRouteConfigsOperations", + "GatewayCustomDomainsOperations", + "ApiPortalsOperations", + "ApiPortalCustomDomainsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_api_portal_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_api_portal_custom_domains_operations.py index 6ababcc56e81..ae184c0911d4 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_api_portal_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_api_portal_custom_domains_operations.py @@ -6,282 +6,287 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, +def build_delete_request( resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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 ApiPortalCustomDomainsOperations(object): - """ApiPortalCustomDomainsOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApiPortalCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`api_portal_custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.ApiPortalCustomDomainResource": + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any + ) -> _models.ApiPortalCustomDomainResource: """Get the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiPortalCustomDomainResource, or the result of cls(response) + :return: ApiPortalCustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore def _create_or_update_initial( self, @@ -289,39 +294,55 @@ def _create_or_update_initial( service_name: str, api_portal_name: str, domain_name: str, - api_portal_custom_domain_resource: "_models.ApiPortalCustomDomainResource", + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], **kwargs: Any - ) -> "_models.ApiPortalCustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] + ) -> _models.ApiPortalCustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(api_portal_custom_domain_resource, 'ApiPortalCustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_custom_domain_resource, (IO, bytes)): + _content = api_portal_custom_domain_resource + else: + _json = self._serialize.body(api_portal_custom_domain_resource, "ApiPortalCustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: @@ -329,18 +350,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: _models.ApiPortalCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -349,24 +458,27 @@ def begin_create_or_update( service_name: str, api_portal_name: str, domain_name: str, - api_portal_custom_domain_resource: "_models.ApiPortalCustomDomainResource", + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.ApiPortalCustomDomainResource"]: + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: """Create or update the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_name: str :param api_portal_custom_domain_resource: The API portal custom domain for the create or update - operation. + operation. Is either a model type or a IO type. Required. :type api_portal_custom_domain_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -379,19 +491,21 @@ def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + 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, service_name=service_name, api_portal_name=api_portal_name, @@ -399,67 +513,75 @@ def begin_create_or_update( api_portal_custom_domain_resource=api_portal_custom_domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: @@ -469,28 +591,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_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. @@ -502,104 +618,122 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any - ) -> Iterable["_models.ApiPortalCustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> Iterable["_models.ApiPortalCustomDomainResource"]: """Handle requests to list all API portal custom domains. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiPortalCustomDomainResourceCollection or the - result of cls(response) + :return: An iterator like instance of either ApiPortalCustomDomainResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, api_portal_name=api_portal_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, - service_name=service_name, - api_portal_name=api_portal_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -613,10 +747,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 @@ -626,8 +758,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_api_portals_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_api_portals_operations.py index 4b3996956aaa..8f20e04ee9d7 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_api_portals_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_api_portals_operations.py @@ -6,354 +6,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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, - service_name: str, - api_portal_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, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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, - service_name: str, - api_portal_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, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_domain_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - api_portal_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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 ApiPortalsOperations(object): - """ApiPortalsOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 ApiPortalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`api_portals` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any - ) -> "_models.ApiPortalResource": + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> _models.ApiPortalResource: """Get the API portal and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiPortalResource, or the result of cls(response) + :return: ApiPortalResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, api_portal_name: str, - api_portal_resource: "_models.ApiPortalResource", + api_portal_resource: Union[_models.ApiPortalResource, IO], **kwargs: Any - ) -> "_models.ApiPortalResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] + ) -> _models.ApiPortalResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(api_portal_resource, 'ApiPortalResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_resource, (IO, bytes)): + _content = api_portal_resource + else: + _json = self._serialize.body(api_portal_resource, "ApiPortalResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: @@ -361,18 +361,97 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: _models.ApiPortalResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -380,20 +459,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, api_portal_name: str, - api_portal_resource: "_models.ApiPortalResource", + api_portal_resource: Union[_models.ApiPortalResource, IO], **kwargs: Any - ) -> LROPoller["_models.ApiPortalResource"]: + ) -> LROPoller[_models.ApiPortalResource]: """Create the default API portal or update the existing API portal. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param api_portal_resource: The API portal for the create or update operation. + :param api_portal_resource: The API portal for the create or update operation. Is either a + model type or a IO type. Required. :type api_portal_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -406,84 +490,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + 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, service_name=service_name, api_portal_name=api_portal_name, api_portal_resource=api_portal_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, api_portal_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: @@ -493,25 +588,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the default API portal. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_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. @@ -523,98 +613,115 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, api_portal_name=api_portal_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.ApiPortalResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.ApiPortalResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiPortalResourceCollection or the result of - cls(response) + :return: An iterator like instance of either ApiPortalResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -628,10 +735,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 @@ -641,79 +746,159 @@ 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.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore - @distributed_trace + @overload def validate_domain( self, resource_group_name: str, service_name: str, api_portal_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the domains are valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_apps_operations.py index 250f8853971c..ea2045934cac 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_apps_operations.py @@ -6,387 +6,350 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, sync_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 sync_status is not None: - _query_parameters['syncStatus'] = _SERIALIZER.query("sync_status", sync_status, 'str') + _params["syncStatus"] = _SERIALIZER.query("sync_status", sync_status, "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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str +def build_list_request(resource_group_name: str, service_name: str, 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_resource_upload_url_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_set_active_deployments_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_set_active_deployments_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_validate_domain_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class AppsOperations(object): - """AppsOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`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 get( @@ -396,102 +359,125 @@ def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -499,21 +485,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -521,20 +586,24 @@ def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -547,84 +616,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -634,25 +714,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -664,83 +739,107 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -748,18 +847,97 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -767,20 +945,24 @@ def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -793,104 +975,120 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AppResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -904,10 +1102,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 @@ -917,112 +1113,129 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore def _set_active_deployments_initial( self, resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(active_deployment_collection, 'ActiveDeploymentCollection') - - request = build_set_active_deployments_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(active_deployment_collection, (IO, bytes)): + _content = active_deployment_collection + else: + _json = self._serialize.body(active_deployment_collection, "ActiveDeploymentCollection") + + request = build_set_active_deployments_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._set_active_deployments_initial.metadata['url'], + content=_content, + template_url=self._set_active_deployments_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]: @@ -1030,18 +1243,98 @@ def _set_active_deployments_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _set_active_deployments_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + _set_active_deployments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + @overload + def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: _models.ActiveDeploymentCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ActiveDeploymentCollection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_set_active_deployments( @@ -1049,21 +1342,25 @@ def begin_set_active_deployments( resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Set existing Deployment under the app as active. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param active_deployment_collection: A list of Deployment name to be active. + :param active_deployment_collection: A list of Deployment name to be active. Is either a model + type or a IO type. Required. :type active_deployment_collection: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.ActiveDeploymentCollection + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ActiveDeploymentCollection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1076,119 +1373,208 @@ def begin_set_active_deployments( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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._set_active_deployments_initial( + raw_result = self._set_active_deployments_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, active_deployment_collection=active_deployment_collection, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_set_active_deployments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + begin_set_active_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore - @distributed_trace + @overload def validate_domain( self, resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_bindings_operations.py index 58353810710c..4bed05a6d0c0 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_bindings_operations.py @@ -6,330 +6,310 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class BindingsOperations(object): - """BindingsOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +317,55 @@ def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -377,21 +373,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +481,27 @@ def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +514,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +536,75 @@ def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -518,28 +614,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -551,46 +641,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _update_initial( self, @@ -598,39 +696,55 @@ def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -638,18 +752,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +857,27 @@ def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +890,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +912,104 @@ def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +1023,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 @@ -816,8 +1034,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_build_service_agent_pool_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_build_service_agent_pool_operations.py index f08381a1a61a..b52baac8aa5a 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_build_service_agent_pool_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_build_service_agent_pool_operations.py @@ -6,233 +6,246 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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, service_name: str, build_service_name: str, agent_pool_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_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_update_put_request_initial( - subscription_id: str, +def build_update_put_request( resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_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 - ) - -class BuildServiceAgentPoolOperations(object): - """BuildServiceAgentPoolOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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) + + +class BuildServiceAgentPoolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`build_service_agent_pool` 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, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildServiceAgentPoolResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.BuildServiceAgentPoolResource"]: """List build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceAgentPoolResourceCollection or the - result of cls(response) + :return: An iterator like instance of either BuildServiceAgentPoolResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -246,10 +259,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 @@ -259,78 +270,78 @@ 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - agent_pool_name: str, - **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": + self, resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: """Get build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildServiceAgentPoolResource, or the result of cls(response) + :return: BuildServiceAgentPoolResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore def _update_put_initial( self, @@ -338,39 +349,55 @@ def _update_put_initial( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] + ) -> _models.BuildServiceAgentPoolResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(agent_pool_resource, 'BuildServiceAgentPoolResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(agent_pool_resource, (IO, bytes)): + _content = agent_pool_resource + else: + _json = self._serialize.body(agent_pool_resource, "BuildServiceAgentPoolResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -378,18 +405,104 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: _models.BuildServiceAgentPoolResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( @@ -398,23 +511,27 @@ def begin_update_put( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> LROPoller["_models.BuildServiceAgentPoolResource"]: + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: """Create or update build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str - :param agent_pool_resource: Parameters for the update operation. + :param agent_pool_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type agent_pool_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -427,19 +544,21 @@ def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceAgentPoolResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, @@ -447,29 +566,34 @@ def begin_update_put( agent_pool_resource=agent_pool_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_build_service_builder_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_build_service_builder_operations.py index 372456dce93c..bd1bf2ba5ff8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_build_service_builder_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_build_service_builder_operations.py @@ -6,282 +6,287 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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, +def build_delete_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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 BuildServiceBuilderOperations(object): - """BuildServiceBuilderOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BuildServiceBuilderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`build_service_builder` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> "_models.BuilderResource": + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.BuilderResource: """Get a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuilderResource, or the result of cls(response) + :return: BuilderResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore def _create_or_update_initial( self, @@ -289,39 +294,55 @@ def _create_or_update_initial( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> "_models.BuilderResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] + ) -> _models.BuilderResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(builder_resource, 'BuilderResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(builder_resource, (IO, bytes)): + _content = builder_resource + else: + _json = self._serialize.body(builder_resource, "BuilderResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -329,18 +350,103 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: _models.BuilderResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -349,22 +455,27 @@ def begin_create_or_update( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> LROPoller["_models.BuilderResource"]: + ) -> LROPoller[_models.BuilderResource]: """Create or update a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param builder_resource: The target builder for the create or update operation. - :type builder_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource + :param builder_resource: The target builder for the create or update operation. Is either a + model type or a IO type. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -377,19 +488,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -397,67 +510,75 @@ def begin_create_or_update( builder_resource=builder_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, build_service_name: str, builder_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -467,28 +588,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_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. @@ -500,104 +615,121 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuilderResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.BuilderResource"]: """List KPack builders result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuilderResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BuilderResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -611,10 +743,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 @@ -624,8 +754,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_build_service_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_build_service_operations.py index 30f21ac6634d..40fc9ebd3cc0 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_build_service_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_build_service_operations.py @@ -6,618 +6,613 @@ # Code generated 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 +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_build_services_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_build_service_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_builds_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_build_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_build_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_list_build_results_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_build_result_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, build_result_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), - "buildResultName": _SERIALIZER.url("build_result_name", build_result_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_name, "str"), + "buildResultName": _SERIALIZER.url("build_result_name", build_result_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_build_result_log_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, build_result_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), - "buildResultName": _SERIALIZER.url("build_result_name", build_result_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_name, "str"), + "buildResultName": _SERIALIZER.url("build_result_name", build_result_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_get_resource_upload_url_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_list_supported_buildpacks_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_supported_buildpack_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildpackName": _SERIALIZER.url("buildpack_name", buildpack_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildpackName": _SERIALIZER.url("buildpack_name", buildpack_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_supported_stacks_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_supported_stack_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "stackName": _SERIALIZER.url("stack_name", stack_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "stackName": _SERIALIZER.url("stack_name", stack_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 BuildServiceOperations(object): - """BuildServiceOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BuildServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`build_service` 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_build_services( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildServiceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.BuildService"]: """List build services resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceCollection or the result of - cls(response) + :return: An iterator like instance of either BuildService or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildServiceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildService] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_services_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_services.metadata['url'], + template_url=self.list_build_services.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_build_services_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -631,10 +626,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 @@ -644,131 +637,141 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_build_services.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore + list_build_services.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore @distributed_trace def get_build_service( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.BuildService": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.BuildService: """Get a build service resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildService, or the result of cls(response) + :return: BuildService or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildService - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildService"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildService] - request = build_get_build_service_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_service.metadata['url'], + template_url=self.get_build_service.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildService', pipeline_response) + deserialized = self._deserialize("BuildService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore - + get_build_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore @distributed_trace def list_builds( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.Build"]: """List KPack builds. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildCollection or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Build or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_builds_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_builds.metadata['url'], + template_url=self.list_builds.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_builds_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -782,10 +785,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 @@ -795,78 +796,146 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_builds.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore + list_builds.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore @distributed_trace def get_build( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> "_models.Build": + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> _models.Build: """Get a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - request = build_get_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build.metadata['url'], + template_url=self.get_build.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + get_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + + @overload + def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: _models.Build, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Build + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update_build( @@ -875,57 +944,77 @@ def create_or_update_build( service_name: str, build_service_name: str, build_name: str, - build: "_models.Build", + build: Union[_models.Build, IO], **kwargs: Any - ) -> "_models.Build": + ) -> _models.Build: """Create or update a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build: Parameters for the create or update operation. - :type build: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Build + :param build: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type build: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Build or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - _json = self._serialize.body(build, 'Build') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build, (IO, bytes)): + _content = build + else: + _json = self._serialize.body(build, "Build") request = build_create_or_update_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_build.metadata['url'], + content=_content, + template_url=self.create_or_update_build.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]: @@ -933,81 +1022,87 @@ def create_or_update_build( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore - + create_or_update_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore @distributed_trace def list_build_results( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildResultCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> Iterable["_models.BuildResult"]: """List KPack build results. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildResultCollection or the result of - cls(response) + :return: An iterator like instance of either BuildResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildResultCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_results_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_results.metadata['url'], + template_url=self.list_build_results.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_build_results_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - build_name=build_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1021,10 +1116,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 @@ -1034,11 +1127,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_build_results.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore + list_build_results.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore @distributed_trace def get_build_result( @@ -1049,67 +1140,74 @@ def get_build_result( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResult": + ) -> _models.BuildResult: """Get a KPack build result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResult, or the result of cls(response) + :return: BuildResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResult] - request = build_get_build_result_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result.metadata['url'], + template_url=self.get_build_result.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResult', pipeline_response) + deserialized = self._deserialize("BuildResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore - + get_build_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore @distributed_trace def get_build_result_log( @@ -1120,387 +1218,407 @@ def get_build_result_log( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResultLog": + ) -> _models.BuildResultLog: """Get a KPack build result log download URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResultLog, or the result of cls(response) + :return: BuildResultLog or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildResultLog - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultLog"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultLog] - request = build_get_build_result_log_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result_log.metadata['url'], + template_url=self.get_build_result_log.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResultLog', pipeline_response) + deserialized = self._deserialize("BuildResultLog", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result_log.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore - + get_build_result_log.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore @distributed_trace def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for build service, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore @distributed_trace def list_supported_buildpacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedBuildpacksCollection: """Get all supported buildpacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpacksCollection, or the result of cls(response) + :return: SupportedBuildpacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.SupportedBuildpacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpacksCollection] - request = build_list_supported_buildpacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_buildpacks.metadata['url'], + template_url=self.list_supported_buildpacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedBuildpacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_buildpacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore - + list_supported_buildpacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore @distributed_trace def get_supported_buildpack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - buildpack_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, **kwargs: Any + ) -> _models.SupportedBuildpackResource: """Get the supported buildpack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param buildpack_name: The name of the buildpack resource. + :param buildpack_name: The name of the buildpack resource. Required. :type buildpack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpackResource, or the result of cls(response) + :return: SupportedBuildpackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.SupportedBuildpackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpackResource] - request = build_get_supported_buildpack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, buildpack_name=buildpack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_buildpack.metadata['url'], + template_url=self.get_supported_buildpack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpackResource', pipeline_response) + deserialized = self._deserialize("SupportedBuildpackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_buildpack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore - + get_supported_buildpack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore @distributed_trace def list_supported_stacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedStacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedStacksCollection: """Get all supported stacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStacksCollection, or the result of cls(response) + :return: SupportedStacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.SupportedStacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStacksCollection] - request = build_list_supported_stacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_stacks.metadata['url'], + template_url=self.list_supported_stacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedStacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_stacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore - + list_supported_stacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore @distributed_trace def get_supported_stack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - stack_name: str, - **kwargs: Any - ) -> "_models.SupportedStackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, **kwargs: Any + ) -> _models.SupportedStackResource: """Get the supported stack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param stack_name: The name of the stack resource. + :param stack_name: The name of the stack resource. Required. :type stack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStackResource, or the result of cls(response) + :return: SupportedStackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.SupportedStackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStackResource] - request = build_get_supported_stack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, stack_name=stack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_stack.metadata['url'], + template_url=self.get_supported_stack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStackResource', pipeline_response) + deserialized = self._deserialize("SupportedStackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_stack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore - + get_supported_stack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_buildpack_binding_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_buildpack_binding_operations.py index 64c9943c8b99..707bb6634c88 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_buildpack_binding_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_buildpack_binding_operations.py @@ -6,223 +6,230 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, buildpack_binding_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), - "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, buildpack_binding_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), - "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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, +def build_delete_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, buildpack_binding_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), - "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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 BuildpackBindingOperations(object): - """BuildpackBindingOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BuildpackBindingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`buildpack_binding` 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( @@ -233,67 +240,74 @@ def get( builder_name: str, buildpack_binding_name: str, **kwargs: Any - ) -> "_models.BuildpackBindingResource": + ) -> _models.BuildpackBindingResource: """Get a buildpack binding by name. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildpackBindingResource, or the result of cls(response) + :return: BuildpackBindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore def _create_or_update_initial( self, @@ -302,40 +316,56 @@ def _create_or_update_initial( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: Union[_models.BuildpackBindingResource, IO], **kwargs: Any - ) -> "_models.BuildpackBindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] + ) -> _models.BuildpackBindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(buildpack_binding, 'BuildpackBindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(buildpack_binding, (IO, bytes)): + _content = buildpack_binding + else: + _json = self._serialize.body(buildpack_binding, "BuildpackBindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -343,20 +373,19 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, @@ -364,25 +393,31 @@ def begin_create_or_update( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: _models.BuildpackBindingResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.BuildpackBindingResource"]: + ) -> LROPoller[_models.BuildpackBindingResource]: """Create or update a buildpack binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. :type buildpack_binding: ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -395,19 +430,114 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] - 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, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. Is + either a model type or a IO type. Required. + :type buildpack_binding: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResource] + :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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -416,32 +546,37 @@ def begin_create_or_update( buildpack_binding=buildpack_binding, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -452,33 +587,41 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements buildpack_binding_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -488,11 +631,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, service_name: str, @@ -504,15 +646,15 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Operation to delete a Buildpack Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_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. @@ -524,110 +666,126 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildpackBindingResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> Iterable["_models.BuildpackBindingResource"]: """Handles requests to list all buildpack bindings in a builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildpackBindingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either BuildpackBindingResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, - service_name=service_name, - build_service_name=build_service_name, - builder_name=builder_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -641,10 +799,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 @@ -654,8 +810,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_certificates_operations.py index f4548d0e160e..ec228ae92b89 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_certificates_operations.py @@ -6,308 +6,317 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - 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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", 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.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'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 get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(certificate_resource, 'CertificateResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -315,21 +324,101 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -337,21 +426,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> LROPoller["_models.CertificateResource"]: + ) -> LROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type certificate_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -364,84 +457,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -451,25 +555,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -481,98 +580,117 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +704,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 @@ -599,8 +715,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_config_servers_operations.py index b96c2738185d..a42f2af16b0a 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_config_servers_operations.py @@ -6,311 +6,311 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_validate_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ConfigServersOperations(object): - """ConfigServersOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -318,37 +318,115 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -361,86 +439,109 @@ def begin_update_put( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -448,37 +549,115 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -491,86 +670,109 @@ def begin_update_patch( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_settings, 'ConfigServerSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -578,37 +780,115 @@ def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerSettings + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -621,47 +901,54 @@ def begin_validate( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_configuration_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_configuration_services_operations.py index 7eb2e2b4b01f..02f8e07e3e3f 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_configuration_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_configuration_services_operations.py @@ -6,354 +6,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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, - service_name: str, - configuration_service_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, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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, - service_name: str, - configuration_service_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, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - configuration_service_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_validate_request( + resource_group_name: str, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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 ConfigurationServicesOperations(object): - """ConfigurationServicesOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 ConfigurationServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`configuration_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any - ) -> "_models.ConfigurationServiceResource": + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> _models.ConfigurationServiceResource: """Get the Application Configuration Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigurationServiceResource, or the result of cls(response) + :return: ConfigurationServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] + ) -> _models.ConfigurationServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(configuration_service_resource, 'ConfigurationServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_service_resource, (IO, bytes)): + _content = configuration_service_resource + else: + _json = self._serialize.body(configuration_service_resource, "ConfigurationServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -361,18 +361,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: _models.ConfigurationServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -380,22 +462,26 @@ def begin_create_or_update( resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigurationServiceResource"]: + ) -> LROPoller[_models.ConfigurationServiceResource]: """Create the default Application Configuration Service or update the existing Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param configuration_service_resource: Parameters for the update operation. + :param configuration_service_resource: Parameters for the update operation. Is either a model + type or a IO type. Required. :type configuration_service_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -408,84 +494,95 @@ def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + 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, service_name=service_name, configuration_service_name=configuration_service_name, configuration_service_resource=configuration_service_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, configuration_service_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -495,25 +592,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any ) -> LROPoller[None]: """Disable the default Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_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. @@ -525,98 +617,118 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, configuration_service_name=configuration_service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.ConfigurationServiceResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.ConfigurationServiceResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationServiceResourceCollection or the - result of cls(response) + :return: An iterator like instance of either ConfigurationServiceResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -630,10 +742,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 @@ -643,49 +753,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore def _validate_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] + ) -> _models.ConfigurationServiceSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(settings, 'ConfigurationServiceSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(settings, (IO, bytes)): + _content = settings + else: + _json = self._serialize.body(settings, "ConfigurationServiceSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -693,18 +817,97 @@ def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: _models.ConfigurationServiceSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_validate( @@ -712,20 +915,25 @@ def begin_validate( resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigurationServiceSettingsValidateResult"]: + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: """Check if the Application Configuration Service settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param settings: Application Configuration Service settings to be validated. + :param settings: Application Configuration Service settings to be validated. Is either a model + type or a IO type. Required. :type settings: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceSettings + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -738,48 +946,55 @@ def begin_validate( ConfigurationServiceSettingsValidateResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ConfigurationServiceSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + 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._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, settings=settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_custom_domains_operations.py index 9949e31c50a2..f06ad18b8926 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_custom_domains_operations.py @@ -6,330 +6,310 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class CustomDomainsOperations(object): - """CustomDomainsOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +317,55 @@ def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -377,21 +373,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +481,27 @@ def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +514,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +536,75 @@ def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -518,28 +614,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -551,46 +641,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _update_initial( self, @@ -598,39 +696,55 @@ def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -638,18 +752,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +857,27 @@ def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +890,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +912,105 @@ def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +1024,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 @@ -816,8 +1035,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_deployments_operations.py index 8a71e1e1f7f6..39b65430aa9a 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_deployments_operations.py @@ -6,678 +6,667 @@ # Code generated 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, List, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_delete_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_for_cluster_request( - subscription_id: str, resource_group_name: str, service_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_start_request_initial( - subscription_id: str, +def build_start_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_stop_request_initial( - subscription_id: str, +def build_stop_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request_initial( - subscription_id: str, +def build_restart_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_get_log_file_url_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_generate_heap_dump_request_initial( - subscription_id: str, +def build_generate_heap_dump_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_generate_thread_dump_request_initial( - subscription_id: str, +def build_generate_thread_dump_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_start_jfr_request_initial( - subscription_id: str, +def build_start_jfr_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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 DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( self, @@ -685,39 +674,55 @@ def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -725,21 +730,107 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -748,23 +839,27 @@ def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -777,19 +872,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -797,67 +894,75 @@ def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -867,28 +972,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -900,46 +999,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _update_initial( self, @@ -947,39 +1054,55 @@ def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -987,18 +1110,104 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -1007,23 +1216,27 @@ def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1036,19 +1249,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -1056,32 +1271,37 @@ def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -1091,60 +1311,72 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + ) -> Iterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1158,10 +1390,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 @@ -1171,69 +1401,76 @@ 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1247,10 +1484,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 @@ -1260,46 +1495,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1309,28 +1545,22 @@ def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1342,81 +1572,92 @@ def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1426,28 +1667,22 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1459,81 +1694,92 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -1543,28 +1789,22 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace - def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1576,98 +1816,109 @@ def begin_restart( # 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1676,15 +1927,14 @@ def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1692,39 +1942,55 @@ def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statemen service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_heap_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_heap_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_heap_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_heap_dump_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]: @@ -1734,33 +2000,119 @@ def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _generate_heap_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + _generate_heap_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + @overload + def begin_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_heap_dump( # pylint: disable=inconsistent-return-statements + def begin_generate_heap_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Generate Heap Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1771,19 +2123,21 @@ def begin_generate_heap_dump( # 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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._generate_heap_dump_initial( + raw_result = self._generate_heap_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1791,29 +2145,35 @@ def begin_generate_heap_dump( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_generate_heap_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + begin_generate_heap_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1821,39 +2181,55 @@ def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statem service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_thread_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_thread_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_thread_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_thread_dump_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]: @@ -1863,33 +2239,119 @@ def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _generate_thread_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + _generate_thread_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + @overload + def begin_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_thread_dump( # pylint: disable=inconsistent-return-statements + def begin_generate_thread_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Generate Thread Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1900,19 +2362,21 @@ def begin_generate_thread_dump( # pylint: disable=inconsistent-return-statement 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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._generate_thread_dump_initial( + raw_result = self._generate_thread_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1920,29 +2384,35 @@ def begin_generate_thread_dump( # pylint: disable=inconsistent-return-statement diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_generate_thread_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + begin_generate_thread_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore def _start_jfr_initial( # pylint: disable=inconsistent-return-statements self, @@ -1950,39 +2420,55 @@ def _start_jfr_initial( # pylint: disable=inconsistent-return-statements service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_start_jfr_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_start_jfr_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._start_jfr_initial.metadata['url'], + content=_content, + template_url=self._start_jfr_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]: @@ -1992,33 +2478,119 @@ def _start_jfr_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_jfr_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + _start_jfr_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + @overload + def begin_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_start_jfr( # pylint: disable=inconsistent-return-statements + def begin_start_jfr( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Start JFR. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_01_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2029,19 +2601,21 @@ def begin_start_jfr( # 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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._start_jfr_initial( + raw_result = self._start_jfr_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -2049,26 +2623,32 @@ def begin_start_jfr( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start_jfr.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + begin_start_jfr.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_gateway_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_gateway_custom_domains_operations.py index 32a152a04a59..2306df749e39 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_gateway_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_gateway_custom_domains_operations.py @@ -6,282 +6,287 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, +def build_delete_request( resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewayCustomDomainsOperations(object): - """GatewayCustomDomainsOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class GatewayCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`gateway_custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.GatewayCustomDomainResource": + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any + ) -> _models.GatewayCustomDomainResource: """Get the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayCustomDomainResource, or the result of cls(response) + :return: GatewayCustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore def _create_or_update_initial( self, @@ -289,39 +294,55 @@ def _create_or_update_initial( service_name: str, gateway_name: str, domain_name: str, - gateway_custom_domain_resource: "_models.GatewayCustomDomainResource", + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], **kwargs: Any - ) -> "_models.GatewayCustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] + ) -> _models.GatewayCustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_custom_domain_resource, 'GatewayCustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_custom_domain_resource, (IO, bytes)): + _content = gateway_custom_domain_resource + else: + _json = self._serialize.body(gateway_custom_domain_resource, "GatewayCustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: @@ -329,18 +350,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: _models.GatewayCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayCustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayCustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -349,24 +458,27 @@ def begin_create_or_update( service_name: str, gateway_name: str, domain_name: str, - gateway_custom_domain_resource: "_models.GatewayCustomDomainResource", + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.GatewayCustomDomainResource"]: + ) -> LROPoller[_models.GatewayCustomDomainResource]: """Create or update the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_name: str :param gateway_custom_domain_resource: The gateway custom domain resource for the create or - update operation. + update operation. Is either a model type or a IO type. Required. :type gateway_custom_domain_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -379,19 +491,21 @@ def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + 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, service_name=service_name, gateway_name=gateway_name, @@ -399,67 +513,75 @@ def begin_create_or_update( gateway_custom_domain_resource=gateway_custom_domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_name: str, domain_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: @@ -469,28 +591,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_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. @@ -502,104 +618,122 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> Iterable["_models.GatewayCustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> Iterable["_models.GatewayCustomDomainResource"]: """Handle requests to list all Spring Cloud Gateway custom domains. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayCustomDomainResourceCollection or the - result of cls(response) + :return: An iterator like instance of either GatewayCustomDomainResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, gateway_name=gateway_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, - service_name=service_name, - gateway_name=gateway_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -613,10 +747,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 @@ -626,8 +758,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_gateway_route_configs_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_gateway_route_configs_operations.py index ea36d09af019..b477ab116e37 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_gateway_route_configs_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_gateway_route_configs_operations.py @@ -6,282 +6,287 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "routeConfigName": _SERIALIZER.url("route_config_name", route_config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_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_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "routeConfigName": _SERIALIZER.url("route_config_name", route_config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_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_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "routeConfigName": _SERIALIZER.url("route_config_name", route_config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_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="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewayRouteConfigsOperations(object): - """GatewayRouteConfigsOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class GatewayRouteConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`gateway_route_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 get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any - ) -> "_models.GatewayRouteConfigResource": + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any + ) -> _models.GatewayRouteConfigResource: """Get the Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayRouteConfigResource, or the result of cls(response) + :return: GatewayRouteConfigResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore def _create_or_update_initial( self, @@ -289,39 +294,55 @@ def _create_or_update_initial( service_name: str, gateway_name: str, route_config_name: str, - gateway_route_config_resource: "_models.GatewayRouteConfigResource", + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], **kwargs: Any - ) -> "_models.GatewayRouteConfigResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] + ) -> _models.GatewayRouteConfigResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_route_config_resource, 'GatewayRouteConfigResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_route_config_resource, (IO, bytes)): + _content = gateway_route_config_resource + else: + _json = self._serialize.body(gateway_route_config_resource, "GatewayRouteConfigResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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]: @@ -329,18 +350,108 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: _models.GatewayRouteConfigResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayRouteConfigResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayRouteConfigResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -349,25 +460,28 @@ def begin_create_or_update( service_name: str, gateway_name: str, route_config_name: str, - gateway_route_config_resource: "_models.GatewayRouteConfigResource", + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], **kwargs: Any - ) -> LROPoller["_models.GatewayRouteConfigResource"]: + ) -> LROPoller[_models.GatewayRouteConfigResource]: """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_name: str :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or - update operation. + update operation. Is either a model type or a IO type. Required. :type gateway_route_config_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -380,19 +494,21 @@ def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + 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, service_name=service_name, gateway_name=gateway_name, @@ -400,67 +516,75 @@ def begin_create_or_update( gateway_route_config_resource=gateway_route_config_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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]: @@ -470,28 +594,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the Spring Cloud Gateway route config. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_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. @@ -503,104 +621,122 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> Iterable["_models.GatewayRouteConfigResourceCollection"]: + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> Iterable["_models.GatewayRouteConfigResource"]: """Handle requests to list all Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayRouteConfigResourceCollection or the result - of cls(response) + :return: An iterator like instance of either GatewayRouteConfigResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, gateway_name=gateway_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, - service_name=service_name, - gateway_name=gateway_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -614,10 +750,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 @@ -627,8 +761,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_gateways_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_gateways_operations.py index 0598ab10638e..9e807f5a486b 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_gateways_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_gateways_operations.py @@ -6,354 +6,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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, - service_name: str, - gateway_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, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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, - service_name: str, - gateway_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, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_domain_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - gateway_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewaysOperations(object): - """GatewaysOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 GatewaysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`gateways` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> "_models.GatewayResource": + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> _models.GatewayResource: """Get the Spring Cloud Gateway and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayResource, or the result of cls(response) + :return: GatewayResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, gateway_name: str, - gateway_resource: "_models.GatewayResource", + gateway_resource: Union[_models.GatewayResource, IO], **kwargs: Any - ) -> "_models.GatewayResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] + ) -> _models.GatewayResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_resource, 'GatewayResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_resource, (IO, bytes)): + _content = gateway_resource + else: + _json = self._serialize.body(gateway_resource, "GatewayResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: @@ -361,18 +361,97 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: _models.GatewayResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -380,20 +459,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, gateway_name: str, - gateway_resource: "_models.GatewayResource", + gateway_resource: Union[_models.GatewayResource, IO], **kwargs: Any - ) -> LROPoller["_models.GatewayResource"]: + ) -> LROPoller[_models.GatewayResource]: """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param gateway_resource: The gateway for the create or update operation. - :type gateway_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource + :param gateway_resource: The gateway for the create or update operation. Is either a model type + or a IO type. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -406,84 +490,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + 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, service_name=service_name, gateway_name=gateway_name, gateway_resource=gateway_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: @@ -493,25 +588,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any ) -> LROPoller[None]: """Disable the default Spring Cloud Gateway. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_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. @@ -523,98 +613,115 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, gateway_name=gateway_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.GatewayResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.GatewayResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayResourceCollection or the result of - cls(response) + :return: An iterator like instance of either GatewayResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -628,10 +735,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 @@ -641,79 +746,159 @@ 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.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore - @distributed_trace + @overload def validate_domain( self, resource_group_name: str, service_name: str, gateway_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the domains are valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_monitoring_settings_operations.py index 77549aec6084..1260c07b019b 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_monitoring_settings_operations.py @@ -6,267 +6,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 MonitoringSettingsOperations(object): - """MonitoringSettingsOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -274,37 +282,115 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -317,86 +403,109 @@ def begin_update_put( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -404,37 +513,115 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation 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,47 +634,54 @@ def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_operations.py index b2d1f7e9bf48..3c64abe11625 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_operations.py @@ -6,111 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - accept = "application/json" +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,10 +147,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 +158,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_runtime_versions_operations.py index b658b5190296..6f1bd8a38b3f 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_runtime_versions_operations.py @@ -6,117 +6,128 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from 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 -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_runtime_versions_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - accept = "application/json" +def build_list_runtime_versions_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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/runtimeVersions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 RuntimeVersionsOperations(object): - """RuntimeVersionsOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_service_registries_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_service_registries_operations.py index 3d6c06c0bb93..ded7ee01af29 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_service_registries_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_service_registries_operations.py @@ -6,294 +6,297 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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, - service_name: str, - service_registry_name: str, - **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, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + _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, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ServiceRegistriesOperations(object): - """ServiceRegistriesOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServiceRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`service_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: """Get the Service Registry and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceRegistryResource, or the result of cls(response) + :return: ServiceRegistryResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceRegistryResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._create_or_update_initial.metadata['url'], + 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]: @@ -301,35 +304,30 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> LROPoller["_models.ServiceRegistryResource"]: + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> LROPoller[_models.ServiceRegistryResource]: """Create the default Service Registry or update the existing Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -343,81 +341,92 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceRegistryResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: @@ -427,25 +436,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> LROPoller[None]: """Disable the default Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -457,98 +461,118 @@ 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-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.ServiceRegistryResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.ServiceRegistryResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceRegistryResourceCollection or the result of + :return: An iterator like instance of either ServiceRegistryResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceRegistryResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceRegistryResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -562,10 +586,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 @@ -575,8 +597,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_services_operations.py index 774c6ec8e3eb..5fe286ae550d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_services_operations.py @@ -6,636 +6,594 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_test_keys_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_regenerate_test_key_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/regenerateTestKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_disable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_enable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_stop_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_stop_request(resource_group_name: str, service_name: str, 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_start_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_check_name_availability_request( - subscription_id: str, - location: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "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 - ) - - -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 ServicesOperations(object): - """ServicesOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -643,39 +601,43 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -688,81 +650,162 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] + :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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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]: @@ -772,22 +815,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -799,80 +836,100 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -880,36 +937,40 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -922,220 +983,379 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] + :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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2022_01_01_preview.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2022_01_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -1145,98 +1365,104 @@ def disable_test_endpoint( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace - def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def enable_test_endpoint(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1246,22 +1472,16 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_stop(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Stop a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -1273,75 +1493,88 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1351,22 +1584,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_start(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Start a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -1378,147 +1605,229 @@ def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - @distributed_trace + @overload def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2022_01_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_01_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(availability_parameters, 'NameAvailabilityParameters') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1532,10 +1841,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 @@ -1545,58 +1852,68 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1610,10 +1927,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 @@ -1623,8 +1938,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_skus_operations.py index eb209b9ed5dc..cf0b62aef9dc 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_skus_operations.py @@ -6,120 +6,140 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 SkusOperations(object): - """SkusOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) + :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -133,10 +153,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 @@ -146,8 +164,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_storages_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_storages_operations.py index 8c38ca3d71a7..0f2f167450b9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_storages_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_01_01_preview/operations/_storages_operations.py @@ -6,308 +6,317 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - storage_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, service_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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.AppPlatform/Spring/{serviceName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - 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, - service_name: str, - storage_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, service_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 StoragesOperations(object): - """StoragesOperations 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.appplatform.v2022_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class StoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_01_01_preview.AppPlatformManagementClient`'s + :attr:`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 get( - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any - ) -> "_models.StorageResource": + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> _models.StorageResource: """Get the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageResource, or the result of cls(response) + :return: StorageResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-01-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> "_models.StorageResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] + ) -> _models.StorageResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(storage_resource, 'StorageResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_resource, (IO, bytes)): + _content = storage_resource + else: + _json = self._serialize.body(storage_resource, "StorageResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -315,21 +324,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: _models.StorageResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -337,20 +425,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> LROPoller["_models.StorageResource"]: + ) -> LROPoller[_models.StorageResource]: """Create or update storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str - :param storage_resource: Parameters for the create or update operation. - :type storage_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource + :param storage_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -363,84 +456,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + 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, service_name=service_name, storage_name=storage_name, storage_resource=storage_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, storage_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-01-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, storage_name=storage_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]: @@ -450,25 +554,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_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. @@ -480,98 +579,115 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + 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, service_name=service_name, storage_name=storage_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.StorageResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.StorageResource"]: """List all the storages of one Azure Spring Cloud instance. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageResourceCollection or the result of - cls(response) + :return: An iterator like instance of either StorageResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_01_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-01-01-preview") # 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", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -585,10 +701,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 @@ -598,8 +712,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/__init__.py index 41ec6d71ff7f..a6bfaa2de14d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_app_platform_management_client.py index a02c226fdda1..ab8f0e4ebb74 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_app_platform_management_client.py @@ -9,20 +9,44 @@ 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 .._serialization import Deserializer, Serializer from ._configuration import AppPlatformManagementClientConfiguration -from .operations import ApiPortalCustomDomainsOperations, ApiPortalsOperations, AppsOperations, BindingsOperations, BuildServiceAgentPoolOperations, BuildServiceBuilderOperations, BuildServiceOperations, BuildpackBindingOperations, CertificatesOperations, ConfigServersOperations, ConfigurationServicesOperations, CustomDomainsOperations, DeploymentsOperations, GatewayCustomDomainsOperations, GatewayRouteConfigsOperations, GatewaysOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServiceRegistriesOperations, ServicesOperations, SkusOperations, StoragesOperations +from .operations import ( + ApiPortalCustomDomainsOperations, + ApiPortalsOperations, + AppsOperations, + BindingsOperations, + BuildServiceAgentPoolOperations, + BuildServiceBuilderOperations, + BuildServiceOperations, + BuildpackBindingOperations, + CertificatesOperations, + ConfigServersOperations, + ConfigurationServicesOperations, + CustomDomainsOperations, + DeploymentsOperations, + GatewayCustomDomainsOperations, + GatewayRouteConfigsOperations, + GatewaysOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServiceRegistriesOperations, + ServicesOperations, + SkusOperations, + StoragesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Cloud. :ivar services: ServicesOperations operations @@ -87,10 +111,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib :ivar api_portal_custom_domains: ApiPortalCustomDomainsOperations operations :vartype api_portal_custom_domains: azure.mgmt.appplatform.v2022_03_01_preview.operations.ApiPortalCustomDomainsOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -108,7 +132,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -117,13 +143,25 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.configuration_services = ConfigurationServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.service_registries = ServiceRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_services = ConfigurationServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_registries = ServiceRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.build_service = BuildServiceOperations(self._client, self._config, self._serialize, self._deserialize) - self.buildpack_binding = BuildpackBindingOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_builder = BuildServiceBuilderOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_agent_pool = BuildServiceAgentPoolOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.buildpack_binding = BuildpackBindingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_builder = BuildServiceBuilderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_agent_pool = BuildServiceAgentPoolOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.storages = StoragesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -131,20 +169,23 @@ def __init__( self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.gateways = GatewaysOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_route_configs = GatewayRouteConfigsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_custom_domains = GatewayCustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_route_configs = GatewayRouteConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gateway_custom_domains = GatewayCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.api_portals = ApiPortalsOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_portal_custom_domains = ApiPortalCustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.api_portal_custom_domains = ApiPortalCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -153,7 +194,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_configuration.py index 20a46c65a9f6..6df6a1033552 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-03-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(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + api_version = kwargs.pop("api_version", "2022-03-01-preview") # type: Literal["2022-03-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_metadata.json b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_metadata.json index 1378e7b1f7af..8264db5b8d6a 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_metadata.json +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}, \"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\": [\"AppPlatformManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -121,4 +121,4 @@ "api_portals": "ApiPortalsOperations", "api_portal_custom_domains": "ApiPortalCustomDomainsOperations" } -} \ No newline at end of file +} diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_vendor.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_vendor.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_version.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_version.py index e7ffc58c0429..92453d8691d9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_version.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.1.0" +VERSION = "6.1.0" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/__init__.py index 44ce4a5043f8..398c48287ad8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._app_platform_management_client import AppPlatformManagementClient -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/_app_platform_management_client.py index 41d1acdf3059..9b9993c76bf6 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/_app_platform_management_client.py @@ -9,20 +9,44 @@ 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 AppPlatformManagementClientConfiguration -from .operations import ApiPortalCustomDomainsOperations, ApiPortalsOperations, AppsOperations, BindingsOperations, BuildServiceAgentPoolOperations, BuildServiceBuilderOperations, BuildServiceOperations, BuildpackBindingOperations, CertificatesOperations, ConfigServersOperations, ConfigurationServicesOperations, CustomDomainsOperations, DeploymentsOperations, GatewayCustomDomainsOperations, GatewayRouteConfigsOperations, GatewaysOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServiceRegistriesOperations, ServicesOperations, SkusOperations, StoragesOperations +from .operations import ( + ApiPortalCustomDomainsOperations, + ApiPortalsOperations, + AppsOperations, + BindingsOperations, + BuildServiceAgentPoolOperations, + BuildServiceBuilderOperations, + BuildServiceOperations, + BuildpackBindingOperations, + CertificatesOperations, + ConfigServersOperations, + ConfigurationServicesOperations, + CustomDomainsOperations, + DeploymentsOperations, + GatewayCustomDomainsOperations, + GatewayRouteConfigsOperations, + GatewaysOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServiceRegistriesOperations, + ServicesOperations, + SkusOperations, + StoragesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Cloud. :ivar services: ServicesOperations operations @@ -87,10 +111,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib :ivar api_portal_custom_domains: ApiPortalCustomDomainsOperations operations :vartype api_portal_custom_domains: azure.mgmt.appplatform.v2022_03_01_preview.aio.operations.ApiPortalCustomDomainsOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -108,7 +132,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -117,13 +143,25 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.configuration_services = ConfigurationServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.service_registries = ServiceRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_services = ConfigurationServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_registries = ServiceRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.build_service = BuildServiceOperations(self._client, self._config, self._serialize, self._deserialize) - self.buildpack_binding = BuildpackBindingOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_builder = BuildServiceBuilderOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_agent_pool = BuildServiceAgentPoolOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.buildpack_binding = BuildpackBindingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_builder = BuildServiceBuilderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_agent_pool = BuildServiceAgentPoolOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.storages = StoragesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -131,20 +169,23 @@ def __init__( self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.gateways = GatewaysOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_route_configs = GatewayRouteConfigsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_custom_domains = GatewayCustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_route_configs = GatewayRouteConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gateway_custom_domains = GatewayCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.api_portals = ApiPortalsOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_portal_custom_domains = ApiPortalCustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.api_portal_custom_domains = ApiPortalCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -153,7 +194,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/_configuration.py index f4327c3935c2..dbf8cc2d5109 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-03-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(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + api_version = kwargs.pop("api_version", "2022-03-01-preview") # type: Literal["2022-03-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/__init__.py index 0da100b4246c..57694a8d82f6 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/__init__.py @@ -30,28 +30,34 @@ from ._api_portals_operations import ApiPortalsOperations from ._api_portal_custom_domains_operations import ApiPortalCustomDomainsOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'ConfigurationServicesOperations', - 'ServiceRegistriesOperations', - 'BuildServiceOperations', - 'BuildpackBindingOperations', - 'BuildServiceBuilderOperations', - 'BuildServiceAgentPoolOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'StoragesOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', - 'GatewaysOperations', - 'GatewayRouteConfigsOperations', - 'GatewayCustomDomainsOperations', - 'ApiPortalsOperations', - 'ApiPortalCustomDomainsOperations', + "ServicesOperations", + "ConfigServersOperations", + "ConfigurationServicesOperations", + "ServiceRegistriesOperations", + "BuildServiceOperations", + "BuildpackBindingOperations", + "BuildServiceBuilderOperations", + "BuildServiceAgentPoolOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "StoragesOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", + "GatewaysOperations", + "GatewayRouteConfigsOperations", + "GatewayCustomDomainsOperations", + "ApiPortalsOperations", + "ApiPortalCustomDomainsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_api_portal_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_api_portal_custom_domains_operations.py index eb85bf5b49b3..85ba531c273e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_api_portal_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_api_portal_custom_domains_operations.py @@ -6,113 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_portal_custom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._api_portal_custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiPortalCustomDomainsOperations: - """ApiPortalCustomDomainsOperations 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 ApiPortalCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`api_portal_custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.ApiPortalCustomDomainResource": + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any + ) -> _models.ApiPortalCustomDomainResource: """Get the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiPortalCustomDomainResource, or the result of cls(response) + :return: ApiPortalCustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +140,55 @@ async def _create_or_update_initial( service_name: str, api_portal_name: str, domain_name: str, - api_portal_custom_domain_resource: "_models.ApiPortalCustomDomainResource", + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], **kwargs: Any - ) -> "_models.ApiPortalCustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] + ) -> _models.ApiPortalCustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(api_portal_custom_domain_resource, 'ApiPortalCustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_custom_domain_resource, (IO, bytes)): + _content = api_portal_custom_domain_resource + else: + _json = self._serialize.body(api_portal_custom_domain_resource, "ApiPortalCustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: @@ -160,18 +196,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: _models.ApiPortalCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,24 +304,27 @@ async def begin_create_or_update( service_name: str, api_portal_name: str, domain_name: str, - api_portal_custom_domain_resource: "_models.ApiPortalCustomDomainResource", + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ApiPortalCustomDomainResource"]: + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: """Create or update the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_name: str :param api_portal_custom_domain_resource: The API portal custom domain for the create or update - operation. + operation. Is either a model type or a IO type. Required. :type api_portal_custom_domain_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -210,19 +337,21 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + 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, service_name=service_name, api_portal_name=api_portal_name, @@ -230,67 +359,76 @@ async def begin_create_or_update( api_portal_custom_domain_resource=api_portal_custom_domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: @@ -300,28 +438,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_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. @@ -333,104 +465,123 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ApiPortalCustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApiPortalCustomDomainResource"]: """Handle requests to list all API portal custom domains. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiPortalCustomDomainResourceCollection or the - result of cls(response) + :return: An iterator like instance of either ApiPortalCustomDomainResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, api_portal_name=api_portal_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, - service_name=service_name, - api_portal_name=api_portal_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -444,10 +595,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 @@ -457,8 +606,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_api_portals_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_api_portals_operations.py index 81191a45a5e7..e7b4c4c2c822 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_api_portals_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_api_portals_operations.py @@ -6,147 +6,185 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_portals_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_validate_domain_request -T = TypeVar('T') +from ...operations._api_portals_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiPortalsOperations: - """ApiPortalsOperations 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 ApiPortalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`api_portals` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any - ) -> "_models.ApiPortalResource": + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> _models.ApiPortalResource: """Get the API portal and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiPortalResource, or the result of cls(response) + :return: ApiPortalResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, api_portal_name: str, - api_portal_resource: "_models.ApiPortalResource", + api_portal_resource: Union[_models.ApiPortalResource, IO], **kwargs: Any - ) -> "_models.ApiPortalResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] + ) -> _models.ApiPortalResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(api_portal_resource, 'ApiPortalResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_resource, (IO, bytes)): + _content = api_portal_resource + else: + _json = self._serialize.body(api_portal_resource, "ApiPortalResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: @@ -154,18 +192,97 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: _models.ApiPortalResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -173,20 +290,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, api_portal_name: str, - api_portal_resource: "_models.ApiPortalResource", + api_portal_resource: Union[_models.ApiPortalResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ApiPortalResource"]: + ) -> AsyncLROPoller[_models.ApiPortalResource]: """Create the default API portal or update the existing API portal. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param api_portal_resource: The API portal for the create or update operation. + :param api_portal_resource: The API portal for the create or update operation. Is either a + model type or a IO type. Required. :type api_portal_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -199,84 +321,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + 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, service_name=service_name, api_portal_name=api_portal_name, api_portal_resource=api_portal_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, api_portal_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: @@ -286,25 +420,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the default API portal. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -316,98 +445,118 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, api_portal_name=api_portal_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ApiPortalResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApiPortalResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiPortalResourceCollection or the result of - cls(response) + :return: An iterator like instance of either ApiPortalResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -421,10 +570,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 @@ -434,79 +581,159 @@ 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.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore - @distributed_trace_async + @overload async def validate_domain( self, resource_group_name: str, service_name: str, api_portal_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the domains are valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_apps_operations.py index 3e3b322b94cc..728e528d647c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_apps_operations.py @@ -6,46 +6,68 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._apps_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_get_resource_upload_url_request, build_list_request, build_set_active_deployments_request_initial, build_update_request_initial, build_validate_domain_request -T = TypeVar('T') +from ...operations._apps_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_get_resource_upload_url_request, + build_list_request, + build_set_active_deployments_request, + build_update_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AppsOperations: - """AppsOperations 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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`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_async async def get( @@ -55,102 +77,125 @@ async def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -158,21 +203,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,20 +304,24 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -206,84 +334,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -293,25 +433,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -323,83 +458,108 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -407,18 +567,97 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -426,20 +665,24 @@ async def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -452,104 +695,121 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncIterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AppResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -563,10 +823,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 @@ -576,112 +834,129 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace_async async def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore async def _set_active_deployments_initial( self, resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(active_deployment_collection, 'ActiveDeploymentCollection') - - request = build_set_active_deployments_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(active_deployment_collection, (IO, bytes)): + _content = active_deployment_collection + else: + _json = self._serialize.body(active_deployment_collection, "ActiveDeploymentCollection") + + request = build_set_active_deployments_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._set_active_deployments_initial.metadata['url'], + content=_content, + template_url=self._set_active_deployments_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]: @@ -689,18 +964,98 @@ async def _set_active_deployments_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _set_active_deployments_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + _set_active_deployments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + + @overload + async def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: _models.ActiveDeploymentCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ActiveDeploymentCollection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_set_active_deployments( @@ -708,21 +1063,25 @@ async def begin_set_active_deployments( resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Set existing Deployment under the app as active. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param active_deployment_collection: A list of Deployment name to be active. + :param active_deployment_collection: A list of Deployment name to be active. Is either a model + type or a IO type. Required. :type active_deployment_collection: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.ActiveDeploymentCollection + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ActiveDeploymentCollection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -735,119 +1094,209 @@ async def begin_set_active_deployments( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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._set_active_deployments_initial( + raw_result = await self._set_active_deployments_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, active_deployment_collection=active_deployment_collection, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_set_active_deployments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + begin_set_active_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore - @distributed_trace_async + @overload async def validate_domain( self, resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_bindings_operations.py index 7989a7b680e5..15cbf5940c88 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_bindings_operations.py @@ -6,113 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._bindings_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._bindings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BindingsOperations: - """BindingsOperations 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 BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +141,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -160,21 +197,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +305,27 @@ async def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +338,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +360,76 @@ async def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -301,28 +439,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -334,46 +466,55 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _update_initial( self, @@ -381,39 +522,55 @@ async def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -421,18 +578,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +683,27 @@ async def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +716,21 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +738,105 @@ async def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +850,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 @@ -599,8 +861,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_build_service_agent_pool_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_build_service_agent_pool_operations.py index bdfca21c53ef..25d533b45032 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_build_service_agent_pool_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_build_service_agent_pool_operations.py @@ -6,104 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._build_service_agent_pool_operations import build_get_request, build_list_request, build_update_put_request_initial -T = TypeVar('T') +from ...operations._build_service_agent_pool_operations import ( + build_get_request, + build_list_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildServiceAgentPoolOperations: - """BuildServiceAgentPoolOperations 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 BuildServiceAgentPoolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service_agent_pool` 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, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildServiceAgentPoolResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildServiceAgentPoolResource"]: """List build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceAgentPoolResourceCollection or the - result of cls(response) + :return: An iterator like instance of either BuildServiceAgentPoolResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -117,10 +144,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 @@ -130,78 +155,78 @@ 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - agent_pool_name: str, - **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": + self, resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: """Get build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildServiceAgentPoolResource, or the result of cls(response) + :return: BuildServiceAgentPoolResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore async def _update_put_initial( self, @@ -209,39 +234,55 @@ async def _update_put_initial( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] + ) -> _models.BuildServiceAgentPoolResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(agent_pool_resource, 'BuildServiceAgentPoolResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(agent_pool_resource, (IO, bytes)): + _content = agent_pool_resource + else: + _json = self._serialize.body(agent_pool_resource, "BuildServiceAgentPoolResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -249,18 +290,104 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: _models.BuildServiceAgentPoolResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( @@ -269,23 +396,27 @@ async def begin_update_put( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BuildServiceAgentPoolResource"]: + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: """Create or update build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str - :param agent_pool_resource: Parameters for the update operation. + :param agent_pool_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type agent_pool_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -298,19 +429,21 @@ async def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, @@ -318,29 +451,35 @@ async def begin_update_put( agent_pool_resource=agent_pool_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_build_service_builder_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_build_service_builder_operations.py index 4a86ced05dc3..8a8db8abefac 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_build_service_builder_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_build_service_builder_operations.py @@ -6,113 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._build_service_builder_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._build_service_builder_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildServiceBuilderOperations: - """BuildServiceBuilderOperations 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 BuildServiceBuilderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service_builder` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> "_models.BuilderResource": + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.BuilderResource: """Get a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuilderResource, or the result of cls(response) + :return: BuilderResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +140,55 @@ async def _create_or_update_initial( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> "_models.BuilderResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] + ) -> _models.BuilderResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(builder_resource, 'BuilderResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(builder_resource, (IO, bytes)): + _content = builder_resource + else: + _json = self._serialize.body(builder_resource, "BuilderResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -160,18 +196,103 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: _models.BuilderResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,22 +301,27 @@ async def begin_create_or_update( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BuilderResource"]: + ) -> AsyncLROPoller[_models.BuilderResource]: """Create or update a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param builder_resource: The target builder for the create or update operation. - :type builder_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource + :param builder_resource: The target builder for the create or update operation. Is either a + model type or a IO type. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -208,19 +334,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -228,67 +356,76 @@ async def begin_create_or_update( builder_resource=builder_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, build_service_name: str, builder_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -298,28 +435,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_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. @@ -331,104 +462,122 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuilderResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuilderResource"]: """List KPack builders result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuilderResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BuilderResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -442,10 +591,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 @@ -455,8 +602,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_build_service_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_build_service_operations.py index 60f92c37f7e8..50abccc61e40 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_build_service_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_build_service_operations.py @@ -6,97 +6,135 @@ # Code generated 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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._build_service_operations import build_create_or_update_build_request, build_get_build_request, build_get_build_result_log_request, build_get_build_result_request, build_get_build_service_request, build_get_resource_upload_url_request, build_get_supported_buildpack_request, build_get_supported_stack_request, build_list_build_results_request, build_list_build_services_request, build_list_builds_request, build_list_supported_buildpacks_request, build_list_supported_stacks_request -T = TypeVar('T') +from ...operations._build_service_operations import ( + build_create_or_update_build_request, + build_get_build_request, + build_get_build_result_log_request, + build_get_build_result_request, + build_get_build_service_request, + build_get_resource_upload_url_request, + build_get_supported_buildpack_request, + build_get_supported_stack_request, + build_list_build_results_request, + build_list_build_services_request, + build_list_builds_request, + build_list_supported_buildpacks_request, + build_list_supported_stacks_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildServiceOperations: - """BuildServiceOperations 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 BuildServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service` 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_build_services( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildServiceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildService"]: """List build services resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceCollection or the result of - cls(response) + :return: An iterator like instance of either BuildService or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildService] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_services_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_services.metadata['url'], + template_url=self.list_build_services.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_build_services_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -110,10 +148,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 @@ -123,131 +159,142 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_build_services.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore + list_build_services.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore @distributed_trace_async async def get_build_service( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.BuildService": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.BuildService: """Get a build service resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildService, or the result of cls(response) + :return: BuildService or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildService - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildService"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildService] - request = build_get_build_service_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_service.metadata['url'], + template_url=self.get_build_service.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildService', pipeline_response) + deserialized = self._deserialize("BuildService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore - + get_build_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore @distributed_trace def list_builds( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Build"]: """List KPack builds. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildCollection or the result of cls(response) + :return: An iterator like instance of either Build or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_builds_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_builds.metadata['url'], + template_url=self.list_builds.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_builds_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -261,10 +308,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 @@ -274,78 +319,146 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_builds.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore + list_builds.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore @distributed_trace_async async def get_build( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> "_models.Build": + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> _models.Build: """Get a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - request = build_get_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build.metadata['url'], + template_url=self.get_build.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + get_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + @overload + async def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: _models.Build, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Build + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update_build( @@ -354,57 +467,77 @@ async def create_or_update_build( service_name: str, build_service_name: str, build_name: str, - build: "_models.Build", + build: Union[_models.Build, IO], **kwargs: Any - ) -> "_models.Build": + ) -> _models.Build: """Create or update a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build: Parameters for the create or update operation. - :type build: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Build + :param build: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type build: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Build or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - _json = self._serialize.body(build, 'Build') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build, (IO, bytes)): + _content = build + else: + _json = self._serialize.body(build, "Build") request = build_create_or_update_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_build.metadata['url'], + content=_content, + template_url=self.create_or_update_build.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]: @@ -412,81 +545,87 @@ async def create_or_update_build( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore - + create_or_update_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore @distributed_trace def list_build_results( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildResultCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildResult"]: """List KPack build results. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildResultCollection or the result of - cls(response) + :return: An iterator like instance of either BuildResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildResultCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_results_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_results.metadata['url'], + template_url=self.list_build_results.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_build_results_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - build_name=build_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -500,10 +639,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 @@ -513,11 +650,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_build_results.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore + list_build_results.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore @distributed_trace_async async def get_build_result( @@ -528,67 +663,74 @@ async def get_build_result( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResult": + ) -> _models.BuildResult: """Get a KPack build result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResult, or the result of cls(response) + :return: BuildResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResult] - request = build_get_build_result_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result.metadata['url'], + template_url=self.get_build_result.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResult', pipeline_response) + deserialized = self._deserialize("BuildResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore - + get_build_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore @distributed_trace_async async def get_build_result_log( @@ -599,387 +741,407 @@ async def get_build_result_log( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResultLog": + ) -> _models.BuildResultLog: """Get a KPack build result log download URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResultLog, or the result of cls(response) + :return: BuildResultLog or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildResultLog - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultLog"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultLog] - request = build_get_build_result_log_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result_log.metadata['url'], + template_url=self.get_build_result_log.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResultLog', pipeline_response) + deserialized = self._deserialize("BuildResultLog", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result_log.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore - + get_build_result_log.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore @distributed_trace_async async def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for build service, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore @distributed_trace_async async def list_supported_buildpacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedBuildpacksCollection: """Get all supported buildpacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpacksCollection, or the result of cls(response) + :return: SupportedBuildpacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.SupportedBuildpacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpacksCollection] - request = build_list_supported_buildpacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_buildpacks.metadata['url'], + template_url=self.list_supported_buildpacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedBuildpacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_buildpacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore - + list_supported_buildpacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore @distributed_trace_async async def get_supported_buildpack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - buildpack_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, **kwargs: Any + ) -> _models.SupportedBuildpackResource: """Get the supported buildpack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param buildpack_name: The name of the buildpack resource. + :param buildpack_name: The name of the buildpack resource. Required. :type buildpack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpackResource, or the result of cls(response) + :return: SupportedBuildpackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.SupportedBuildpackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpackResource] - request = build_get_supported_buildpack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, buildpack_name=buildpack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_buildpack.metadata['url'], + template_url=self.get_supported_buildpack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpackResource', pipeline_response) + deserialized = self._deserialize("SupportedBuildpackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_buildpack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore - + get_supported_buildpack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore @distributed_trace_async async def list_supported_stacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedStacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedStacksCollection: """Get all supported stacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStacksCollection, or the result of cls(response) + :return: SupportedStacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.SupportedStacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStacksCollection] - request = build_list_supported_stacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_stacks.metadata['url'], + template_url=self.list_supported_stacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedStacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_stacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore - + list_supported_stacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore @distributed_trace_async async def get_supported_stack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - stack_name: str, - **kwargs: Any - ) -> "_models.SupportedStackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, **kwargs: Any + ) -> _models.SupportedStackResource: """Get the supported stack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param stack_name: The name of the stack resource. + :param stack_name: The name of the stack resource. Required. :type stack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStackResource, or the result of cls(response) + :return: SupportedStackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.SupportedStackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStackResource] - request = build_get_supported_stack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, stack_name=stack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_stack.metadata['url'], + template_url=self.get_supported_stack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStackResource', pipeline_response) + deserialized = self._deserialize("SupportedStackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_stack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore - + get_supported_stack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_buildpack_binding_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_buildpack_binding_operations.py index aa6c16502f50..14d6ba1bc576 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_buildpack_binding_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_buildpack_binding_operations.py @@ -6,46 +6,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._buildpack_binding_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._buildpack_binding_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildpackBindingOperations: - """BuildpackBindingOperations 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 BuildpackBindingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`buildpack_binding` 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( @@ -56,67 +74,74 @@ async def get( builder_name: str, buildpack_binding_name: str, **kwargs: Any - ) -> "_models.BuildpackBindingResource": + ) -> _models.BuildpackBindingResource: """Get a buildpack binding by name. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildpackBindingResource, or the result of cls(response) + :return: BuildpackBindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore async def _create_or_update_initial( self, @@ -125,40 +150,56 @@ async def _create_or_update_initial( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: Union[_models.BuildpackBindingResource, IO], **kwargs: Any - ) -> "_models.BuildpackBindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] + ) -> _models.BuildpackBindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(buildpack_binding, 'BuildpackBindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(buildpack_binding, (IO, bytes)): + _content = buildpack_binding + else: + _json = self._serialize.body(buildpack_binding, "BuildpackBindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -166,20 +207,19 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, @@ -187,25 +227,31 @@ async def begin_create_or_update( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: _models.BuildpackBindingResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.BuildpackBindingResource"]: + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: """Create or update a buildpack binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. :type buildpack_binding: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -218,19 +264,114 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] - 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, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildpackBindingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. Is + either a model type or a IO type. Required. + :type buildpack_binding: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildpackBindingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResource] + :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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -239,32 +380,38 @@ async def begin_create_or_update( buildpack_binding=buildpack_binding, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -275,33 +422,41 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements buildpack_binding_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -311,11 +466,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, service_name: str, @@ -327,15 +481,15 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Operation to delete a Buildpack Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_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. @@ -347,110 +501,127 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildpackBindingResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildpackBindingResource"]: """Handles requests to list all buildpack bindings in a builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildpackBindingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either BuildpackBindingResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, - service_name=service_name, - build_service_name=build_service_name, - builder_name=builder_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -464,10 +635,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 @@ -477,8 +646,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_certificates_operations.py index 2f9c98801dfc..940898f90afd 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_certificates_operations.py @@ -6,147 +6,184 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'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_async async def get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(certificate_resource, 'CertificateResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -154,21 +191,101 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -176,21 +293,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CertificateResource"]: + ) -> AsyncLROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type certificate_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -203,84 +324,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -290,25 +423,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -320,98 +448,118 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -425,10 +573,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 @@ -438,8 +584,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_config_servers_operations.py index eb86aa5b6803..5b4937c9f16f 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_config_servers_operations.py @@ -6,139 +6,174 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._config_servers_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial, build_validate_request_initial -T = TypeVar('T') +from ...operations._config_servers_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConfigServersOperations: - """ConfigServersOperations 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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,37 +181,115 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,86 +302,110 @@ async def begin_update_put( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -276,37 +413,115 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -319,86 +534,110 @@ async def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_settings, 'ConfigServerSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -406,37 +645,115 @@ async def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerSettings + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -449,47 +766,54 @@ async def begin_validate( or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = await self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_configuration_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_configuration_services_operations.py index 1a7089b8ab84..9c5193af2c00 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_configuration_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_configuration_services_operations.py @@ -6,147 +6,185 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._configuration_services_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_validate_request_initial -T = TypeVar('T') +from ...operations._configuration_services_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConfigurationServicesOperations: - """ConfigurationServicesOperations 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 ConfigurationServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`configuration_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any - ) -> "_models.ConfigurationServiceResource": + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> _models.ConfigurationServiceResource: """Get the Application Configuration Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigurationServiceResource, or the result of cls(response) + :return: ConfigurationServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] + ) -> _models.ConfigurationServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(configuration_service_resource, 'ConfigurationServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_service_resource, (IO, bytes)): + _content = configuration_service_resource + else: + _json = self._serialize.body(configuration_service_resource, "ConfigurationServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -154,18 +192,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: _models.ConfigurationServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -173,22 +293,26 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigurationServiceResource"]: + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: """Create the default Application Configuration Service or update the existing Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param configuration_service_resource: Parameters for the update operation. + :param configuration_service_resource: Parameters for the update operation. Is either a model + type or a IO type. Required. :type configuration_service_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -201,84 +325,96 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + 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, service_name=service_name, configuration_service_name=configuration_service_name, configuration_service_resource=configuration_service_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, configuration_service_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -288,25 +424,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Disable the default Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -318,98 +449,119 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, configuration_service_name=configuration_service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ConfigurationServiceResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationServiceResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationServiceResourceCollection or the - result of cls(response) + :return: An iterator like instance of either ConfigurationServiceResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -423,10 +575,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 @@ -436,49 +586,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore async def _validate_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] + ) -> _models.ConfigurationServiceSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(settings, 'ConfigurationServiceSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(settings, (IO, bytes)): + _content = settings + else: + _json = self._serialize.body(settings, "ConfigurationServiceSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -486,18 +650,97 @@ async def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: _models.ConfigurationServiceSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_validate( @@ -505,20 +748,25 @@ async def begin_validate( resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigurationServiceSettingsValidateResult"]: + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: """Check if the Application Configuration Service settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param settings: Application Configuration Service settings to be validated. + :param settings: Application Configuration Service settings to be validated. Is either a model + type or a IO type. Required. :type settings: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceSettings + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -531,48 +779,55 @@ async def begin_validate( ConfigurationServiceSettingsValidateResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + 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._validate_initial( + raw_result = await self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, settings=settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_custom_domains_operations.py index 16ef55ae2d7d..d8d14f715a7a 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_custom_domains_operations.py @@ -6,113 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._custom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CustomDomainsOperations: - """CustomDomainsOperations 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 CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +141,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -160,21 +197,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +305,27 @@ async def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +338,21 @@ async def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +360,76 @@ async def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -301,28 +439,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -334,46 +466,55 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _update_initial( self, @@ -381,39 +522,55 @@ async def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -421,18 +578,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +683,27 @@ async def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +716,21 @@ async def begin_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +738,106 @@ async def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +851,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 @@ -599,8 +862,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_deployments_operations.py index 0aa9463a0820..9d93f334492e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_deployments_operations.py @@ -6,113 +6,142 @@ # Code generated 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, List, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._deployments_operations import build_create_or_update_request_initial, build_delete_request_initial, build_generate_heap_dump_request_initial, build_generate_thread_dump_request_initial, build_get_log_file_url_request, build_get_request, build_list_for_cluster_request, build_list_request, build_restart_request_initial, build_start_jfr_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._deployments_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_heap_dump_request, + build_generate_thread_dump_request, + build_get_log_file_url_request, + build_get_request, + build_list_for_cluster_request, + build_list_request, + build_restart_request, + build_start_jfr_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations 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 DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +149,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -160,21 +205,107 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,23 +314,27 @@ async def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -212,19 +347,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -232,67 +369,76 @@ async def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -302,28 +448,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -335,46 +475,55 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _update_initial( self, @@ -382,39 +531,55 @@ async def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -422,18 +587,104 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -442,23 +693,27 @@ async def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -471,19 +726,21 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -491,32 +748,38 @@ async def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -526,60 +789,72 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + ) -> AsyncIterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -593,10 +868,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 @@ -606,69 +879,76 @@ 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -682,10 +962,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 @@ -695,46 +973,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -744,28 +1023,22 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -777,81 +1050,93 @@ async def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -861,28 +1146,22 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -894,81 +1173,93 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore async def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -978,28 +1269,22 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async - async def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1011,98 +1296,110 @@ async def begin_restart( # 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async async def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1111,15 +1408,14 @@ async def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1127,39 +1423,55 @@ async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-st service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_heap_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_heap_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_heap_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_heap_dump_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]: @@ -1169,33 +1481,119 @@ async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - _generate_heap_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + _generate_heap_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + @overload + async def begin_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_heap_dump( # pylint: disable=inconsistent-return-statements + async def begin_generate_heap_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Generate Heap Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1206,19 +1604,21 @@ async def begin_generate_heap_dump( # pylint: disable=inconsistent-return-state 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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._generate_heap_dump_initial( + raw_result = await self._generate_heap_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1226,29 +1626,36 @@ async def begin_generate_heap_dump( # pylint: disable=inconsistent-return-state diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_generate_heap_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + begin_generate_heap_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1256,39 +1663,55 @@ async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return- service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_thread_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_thread_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_thread_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_thread_dump_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]: @@ -1298,33 +1721,119 @@ async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return- if cls: return cls(pipeline_response, None, {}) - _generate_thread_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + _generate_thread_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + @overload + async def begin_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_thread_dump( # pylint: disable=inconsistent-return-statements + async def begin_generate_thread_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Generate Thread Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1335,19 +1844,21 @@ async def begin_generate_thread_dump( # pylint: disable=inconsistent-return-sta 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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._generate_thread_dump_initial( + raw_result = await self._generate_thread_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1355,29 +1866,36 @@ async def begin_generate_thread_dump( # pylint: disable=inconsistent-return-sta diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_generate_thread_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + begin_generate_thread_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements self, @@ -1385,39 +1903,55 @@ async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_start_jfr_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_start_jfr_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._start_jfr_initial.metadata['url'], + content=_content, + template_url=self._start_jfr_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]: @@ -1427,33 +1961,119 @@ async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_jfr_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + _start_jfr_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + + @overload + async def begin_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_start_jfr( # pylint: disable=inconsistent-return-statements + async def begin_start_jfr( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Start JFR. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1464,19 +2084,21 @@ async def begin_start_jfr( # 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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._start_jfr_initial( + raw_result = await self._start_jfr_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1484,26 +2106,33 @@ async def begin_start_jfr( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start_jfr.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + begin_start_jfr.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_gateway_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_gateway_custom_domains_operations.py index f995109bebe9..4562787b5a96 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_gateway_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_gateway_custom_domains_operations.py @@ -6,113 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._gateway_custom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._gateway_custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GatewayCustomDomainsOperations: - """GatewayCustomDomainsOperations 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 GatewayCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateway_custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.GatewayCustomDomainResource": + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any + ) -> _models.GatewayCustomDomainResource: """Get the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayCustomDomainResource, or the result of cls(response) + :return: GatewayCustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +140,55 @@ async def _create_or_update_initial( service_name: str, gateway_name: str, domain_name: str, - gateway_custom_domain_resource: "_models.GatewayCustomDomainResource", + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], **kwargs: Any - ) -> "_models.GatewayCustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] + ) -> _models.GatewayCustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_custom_domain_resource, 'GatewayCustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_custom_domain_resource, (IO, bytes)): + _content = gateway_custom_domain_resource + else: + _json = self._serialize.body(gateway_custom_domain_resource, "GatewayCustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: @@ -160,18 +196,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: _models.GatewayCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,24 +304,27 @@ async def begin_create_or_update( service_name: str, gateway_name: str, domain_name: str, - gateway_custom_domain_resource: "_models.GatewayCustomDomainResource", + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GatewayCustomDomainResource"]: + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: """Create or update the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_name: str :param gateway_custom_domain_resource: The gateway custom domain resource for the create or - update operation. + update operation. Is either a model type or a IO type. Required. :type gateway_custom_domain_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -210,19 +337,21 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + 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, service_name=service_name, gateway_name=gateway_name, @@ -230,67 +359,76 @@ async def begin_create_or_update( gateway_custom_domain_resource=gateway_custom_domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_name: str, domain_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: @@ -300,28 +438,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_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. @@ -333,104 +465,123 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.GatewayCustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayCustomDomainResource"]: """Handle requests to list all Spring Cloud Gateway custom domains. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayCustomDomainResourceCollection or the - result of cls(response) + :return: An iterator like instance of either GatewayCustomDomainResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, gateway_name=gateway_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, - service_name=service_name, - gateway_name=gateway_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -444,10 +595,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 @@ -457,8 +606,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_gateway_route_configs_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_gateway_route_configs_operations.py index e7a4938113f3..df0043e41025 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_gateway_route_configs_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_gateway_route_configs_operations.py @@ -6,113 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._gateway_route_configs_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._gateway_route_configs_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GatewayRouteConfigsOperations: - """GatewayRouteConfigsOperations 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 GatewayRouteConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateway_route_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_async async def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any - ) -> "_models.GatewayRouteConfigResource": + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any + ) -> _models.GatewayRouteConfigResource: """Get the Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayRouteConfigResource, or the result of cls(response) + :return: GatewayRouteConfigResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +140,55 @@ async def _create_or_update_initial( service_name: str, gateway_name: str, route_config_name: str, - gateway_route_config_resource: "_models.GatewayRouteConfigResource", + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], **kwargs: Any - ) -> "_models.GatewayRouteConfigResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] + ) -> _models.GatewayRouteConfigResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_route_config_resource, 'GatewayRouteConfigResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_route_config_resource, (IO, bytes)): + _content = gateway_route_config_resource + else: + _json = self._serialize.body(gateway_route_config_resource, "GatewayRouteConfigResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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]: @@ -160,18 +196,108 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: _models.GatewayRouteConfigResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayRouteConfigResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayRouteConfigResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,25 +306,28 @@ async def begin_create_or_update( service_name: str, gateway_name: str, route_config_name: str, - gateway_route_config_resource: "_models.GatewayRouteConfigResource", + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GatewayRouteConfigResource"]: + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_name: str :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or - update operation. + update operation. Is either a model type or a IO type. Required. :type gateway_route_config_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +340,21 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + 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, service_name=service_name, gateway_name=gateway_name, @@ -231,67 +362,76 @@ async def begin_create_or_update( gateway_route_config_resource=gateway_route_config_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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]: @@ -301,28 +441,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the Spring Cloud Gateway route config. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_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. @@ -334,104 +468,123 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.GatewayRouteConfigResourceCollection"]: + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayRouteConfigResource"]: """Handle requests to list all Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayRouteConfigResourceCollection or the result - of cls(response) + :return: An iterator like instance of either GatewayRouteConfigResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, gateway_name=gateway_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, - service_name=service_name, - gateway_name=gateway_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -445,10 +598,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 @@ -458,8 +609,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_gateways_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_gateways_operations.py index 4e5d0927d6ac..842f7596c91d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_gateways_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_gateways_operations.py @@ -6,147 +6,185 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._gateways_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_validate_domain_request -T = TypeVar('T') +from ...operations._gateways_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GatewaysOperations: - """GatewaysOperations 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 GatewaysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateways` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> "_models.GatewayResource": + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> _models.GatewayResource: """Get the Spring Cloud Gateway and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayResource, or the result of cls(response) + :return: GatewayResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, gateway_name: str, - gateway_resource: "_models.GatewayResource", + gateway_resource: Union[_models.GatewayResource, IO], **kwargs: Any - ) -> "_models.GatewayResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] + ) -> _models.GatewayResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_resource, 'GatewayResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_resource, (IO, bytes)): + _content = gateway_resource + else: + _json = self._serialize.body(gateway_resource, "GatewayResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: @@ -154,18 +192,97 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: _models.GatewayResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -173,20 +290,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, gateway_name: str, - gateway_resource: "_models.GatewayResource", + gateway_resource: Union[_models.GatewayResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GatewayResource"]: + ) -> AsyncLROPoller[_models.GatewayResource]: """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param gateway_resource: The gateway for the create or update operation. - :type gateway_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource + :param gateway_resource: The gateway for the create or update operation. Is either a model type + or a IO type. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -199,84 +321,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + 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, service_name=service_name, gateway_name=gateway_name, gateway_resource=gateway_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: @@ -286,25 +420,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Disable the default Spring Cloud Gateway. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -316,98 +445,118 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, gateway_name=gateway_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.GatewayResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayResourceCollection or the result of - cls(response) + :return: An iterator like instance of either GatewayResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -421,10 +570,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 @@ -434,79 +581,159 @@ 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.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore - @distributed_trace_async + @overload async def validate_domain( self, resource_group_name: str, service_name: str, gateway_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the domains are valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_monitoring_settings_operations.py index 300216417b07..e7a06a0a834e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_monitoring_settings_operations.py @@ -6,139 +6,175 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._monitoring_settings_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial -T = TypeVar('T') +from ...operations._monitoring_settings_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MonitoringSettingsOperations: - """MonitoringSettingsOperations 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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,37 +182,115 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,86 +303,110 @@ async def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -276,37 +414,115 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -319,47 +535,55 @@ async def begin_update_patch( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_operations.py index 361418cd51e8..6d8344a61d16 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_operations.py @@ -6,82 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.appplatform.v2022_03_01_preview.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,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 @@ -108,8 +134,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_runtime_versions_operations.py index de591e0bc631..e979ac27447e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_runtime_versions_operations.py @@ -6,88 +6,104 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import 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._runtime_versions_operations import build_list_runtime_versions_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RuntimeVersionsOperations: - """RuntimeVersionsOperations 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 RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + async def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_service_registries_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_service_registries_operations.py index 8280787fcd05..c88d1ae2cb9d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_service_registries_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_service_registries_operations.py @@ -6,142 +6,167 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._service_registries_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._service_registries_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ServiceRegistriesOperations: - """ServiceRegistriesOperations 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 ServiceRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`service_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: """Get the Service Registry and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceRegistryResource, or the result of cls(response) + :return: ServiceRegistryResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceRegistryResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._create_or_update_initial.metadata['url'], + 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]: @@ -149,35 +174,30 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace_async async def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceRegistryResource"]: + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceRegistryResource]: """Create the default Service Registry or update the existing Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -191,81 +211,93 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceRegistryResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: @@ -275,25 +307,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Disable the default Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -305,98 +332,119 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceRegistryResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServiceRegistryResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceRegistryResourceCollection or the result of + :return: An iterator like instance of either ServiceRegistryResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceRegistryResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceRegistryResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -410,10 +458,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 @@ -423,8 +469,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_services_operations.py index 33d5db18689d..b308c9f3282b 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_services_operations.py @@ -6,141 +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, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._services_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_disable_test_endpoint_request, build_enable_test_endpoint_request, build_get_request, build_list_by_subscription_request, build_list_request, build_list_test_keys_request, build_regenerate_test_key_request, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._services_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_disable_test_endpoint_request, + build_enable_test_endpoint_request, + build_get_request, + build_list_by_subscription_request, + build_list_request, + build_list_test_keys_request, + build_regenerate_test_key_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ServicesOperations: - """ServicesOperations 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 ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -148,39 +189,43 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -193,81 +238,163 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] + :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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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]: @@ -277,22 +404,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -304,80 +425,101 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -385,36 +527,40 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -427,220 +573,380 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] + :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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + async def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2022_03_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace_async async def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -650,98 +956,106 @@ async def disable_test_endpoint( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace_async async def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -751,22 +1065,16 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_stop(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Stop a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -778,75 +1086,89 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -856,22 +1178,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_start(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Start a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -883,147 +1199,230 @@ async def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2022_03_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(availability_parameters, 'NameAvailabilityParameters') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1037,10 +1436,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 @@ -1050,58 +1447,68 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1115,10 +1522,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 @@ -1128,8 +1533,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_skus_operations.py index e9236ff4f7c5..0088fee8db35 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_skus_operations.py @@ -6,85 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SkusOperations: - """SkusOperations 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 SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) + :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -98,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 @@ -111,8 +135,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_storages_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_storages_operations.py index b9f288e180a8..088731fee289 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_storages_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/aio/operations/_storages_operations.py @@ -6,147 +6,184 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._storages_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._storages_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StoragesOperations: - """StoragesOperations 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 StoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.aio.AppPlatformManagementClient`'s + :attr:`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 get( - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any - ) -> "_models.StorageResource": + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> _models.StorageResource: """Get the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageResource, or the result of cls(response) + :return: StorageResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> "_models.StorageResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] + ) -> _models.StorageResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(storage_resource, 'StorageResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_resource, (IO, bytes)): + _content = storage_resource + else: + _json = self._serialize.body(storage_resource, "StorageResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -154,21 +191,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: _models.StorageResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -176,20 +292,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.StorageResource"]: + ) -> AsyncLROPoller[_models.StorageResource]: """Create or update storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str - :param storage_resource: Parameters for the create or update operation. - :type storage_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource + :param storage_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -202,84 +323,96 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + 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, service_name=service_name, storage_name=storage_name, storage_resource=storage_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, storage_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, storage_name=storage_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]: @@ -289,25 +422,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_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. @@ -319,98 +447,118 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, storage_name=storage_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.StorageResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageResource"]: """List all the storages of one Azure Spring Cloud instance. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageResourceCollection or the result of - cls(response) + :return: An iterator like instance of either StorageResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -424,10 +572,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 @@ -437,8 +583,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/__init__.py index b80473e23b39..f4a716f6f65b 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/__init__.py @@ -174,238 +174,240 @@ from ._models_py3 import UserSourceInfo from ._models_py3 import ValidationMessages - -from ._app_platform_management_client_enums import ( - ActionType, - ApiPortalProvisioningState, - AppResourceProvisioningState, - BindingType, - BuildProvisioningState, - BuildResultProvisioningState, - BuildServiceProvisioningState, - BuilderProvisioningState, - BuildpackBindingProvisioningState, - ConfigServerState, - ConfigurationServiceProvisioningState, - CreatedByType, - DeploymentResourceProvisioningState, - DeploymentResourceStatus, - GatewayProvisioningState, - KPackBuildStageProvisioningState, - LastModifiedByType, - ManagedIdentityType, - MonitoringSettingState, - PowerState, - ProvisioningState, - ResourceSkuRestrictionsReasonCode, - ResourceSkuRestrictionsType, - ServiceRegistryProvisioningState, - SkuScaleType, - StorageType, - SupportedRuntimePlatform, - SupportedRuntimeValue, - TestKeyType, - TrafficDirection, - Type, -) +from ._app_platform_management_client_enums import ActionType +from ._app_platform_management_client_enums import ApiPortalProvisioningState +from ._app_platform_management_client_enums import AppResourceProvisioningState +from ._app_platform_management_client_enums import BindingType +from ._app_platform_management_client_enums import BuildProvisioningState +from ._app_platform_management_client_enums import BuildResultProvisioningState +from ._app_platform_management_client_enums import BuildServiceProvisioningState +from ._app_platform_management_client_enums import BuilderProvisioningState +from ._app_platform_management_client_enums import BuildpackBindingProvisioningState +from ._app_platform_management_client_enums import ConfigServerState +from ._app_platform_management_client_enums import ConfigurationServiceProvisioningState +from ._app_platform_management_client_enums import CreatedByType +from ._app_platform_management_client_enums import DeploymentResourceProvisioningState +from ._app_platform_management_client_enums import DeploymentResourceStatus +from ._app_platform_management_client_enums import GatewayProvisioningState +from ._app_platform_management_client_enums import KPackBuildStageProvisioningState +from ._app_platform_management_client_enums import LastModifiedByType +from ._app_platform_management_client_enums import ManagedIdentityType +from ._app_platform_management_client_enums import MonitoringSettingState +from ._app_platform_management_client_enums import PowerState +from ._app_platform_management_client_enums import ProvisioningState +from ._app_platform_management_client_enums import ResourceSkuRestrictionsReasonCode +from ._app_platform_management_client_enums import ResourceSkuRestrictionsType +from ._app_platform_management_client_enums import ServiceRegistryProvisioningState +from ._app_platform_management_client_enums import SkuScaleType +from ._app_platform_management_client_enums import StorageType +from ._app_platform_management_client_enums import SupportedRuntimePlatform +from ._app_platform_management_client_enums import SupportedRuntimeValue +from ._app_platform_management_client_enums import TestKeyType +from ._app_platform_management_client_enums import TrafficDirection +from ._app_platform_management_client_enums import Type +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__ = [ - 'ActiveDeploymentCollection', - 'ApiPortalCustomDomainProperties', - 'ApiPortalCustomDomainResource', - 'ApiPortalCustomDomainResourceCollection', - 'ApiPortalInstance', - 'ApiPortalProperties', - 'ApiPortalResource', - 'ApiPortalResourceCollection', - 'ApiPortalResourceRequests', - 'AppResource', - 'AppResourceCollection', - 'AppResourceProperties', - 'ApplicationInsightsAgentVersions', - 'AvailableOperations', - 'AvailableRuntimeVersions', - 'AzureFileVolume', - 'BindingResource', - 'BindingResourceCollection', - 'BindingResourceProperties', - 'Build', - 'BuildCollection', - 'BuildProperties', - 'BuildResult', - 'BuildResultCollection', - 'BuildResultLog', - 'BuildResultProperties', - 'BuildResultUserSourceInfo', - 'BuildService', - 'BuildServiceAgentPoolProperties', - 'BuildServiceAgentPoolResource', - 'BuildServiceAgentPoolResourceCollection', - 'BuildServiceAgentPoolSizeProperties', - 'BuildServiceCollection', - 'BuildServiceProperties', - 'BuildServicePropertiesResourceRequests', - 'BuildStageProperties', - 'BuilderProperties', - 'BuilderResource', - 'BuilderResourceCollection', - 'BuildpackBindingLaunchProperties', - 'BuildpackBindingProperties', - 'BuildpackBindingResource', - 'BuildpackBindingResourceCollection', - 'BuildpackProperties', - 'BuildpacksGroupProperties', - 'CertificateProperties', - 'CertificateResource', - 'CertificateResourceCollection', - 'CloudErrorBody', - 'ClusterResourceProperties', - 'ConfigServerGitProperty', - 'ConfigServerProperties', - 'ConfigServerResource', - 'ConfigServerSettings', - 'ConfigServerSettingsErrorRecord', - 'ConfigServerSettingsValidateResult', - 'ConfigurationServiceGitProperty', - 'ConfigurationServiceGitPropertyValidateResult', - 'ConfigurationServiceGitRepository', - 'ConfigurationServiceInstance', - 'ConfigurationServiceProperties', - 'ConfigurationServiceResource', - 'ConfigurationServiceResourceCollection', - 'ConfigurationServiceResourceRequests', - 'ConfigurationServiceSettings', - 'ConfigurationServiceSettingsValidateResult', - 'ContainerProbeSettings', - 'ContentCertificateProperties', - 'CustomContainer', - 'CustomContainerUserSourceInfo', - 'CustomDomainProperties', - 'CustomDomainResource', - 'CustomDomainResourceCollection', - 'CustomDomainValidatePayload', - 'CustomDomainValidateResult', - 'CustomPersistentDiskProperties', - 'CustomPersistentDiskResource', - 'DeploymentInstance', - 'DeploymentResource', - 'DeploymentResourceCollection', - 'DeploymentResourceProperties', - 'DeploymentSettings', - 'DiagnosticParameters', - 'Error', - 'GatewayApiMetadataProperties', - 'GatewayApiRoute', - 'GatewayCorsProperties', - 'GatewayCustomDomainProperties', - 'GatewayCustomDomainResource', - 'GatewayCustomDomainResourceCollection', - 'GatewayInstance', - 'GatewayOperatorProperties', - 'GatewayOperatorResourceRequests', - 'GatewayProperties', - 'GatewayResource', - 'GatewayResourceCollection', - 'GatewayResourceRequests', - 'GatewayRouteConfigProperties', - 'GatewayRouteConfigResource', - 'GatewayRouteConfigResourceCollection', - 'GitPatternRepository', - 'ImageRegistryCredential', - 'JarUploadedUserSourceInfo', - 'KeyVaultCertificateProperties', - 'LoadedCertificate', - 'LogFileUrlResponse', - 'LogSpecification', - 'ManagedIdentityProperties', - 'MetricDimension', - 'MetricSpecification', - 'MonitoringSettingProperties', - 'MonitoringSettingResource', - 'NameAvailability', - 'NameAvailabilityParameters', - 'NetCoreZipUploadedUserSourceInfo', - 'NetworkProfile', - 'NetworkProfileOutboundIPs', - 'OperationDetail', - 'OperationDisplay', - 'OperationProperties', - 'PersistentDisk', - 'ProxyResource', - 'RegenerateTestKeyRequestPayload', - 'RequiredTraffic', - 'Resource', - 'ResourceRequests', - 'ResourceSku', - 'ResourceSkuCapabilities', - 'ResourceSkuCollection', - 'ResourceSkuLocationInfo', - 'ResourceSkuRestrictionInfo', - 'ResourceSkuRestrictions', - 'ResourceSkuZoneDetails', - 'ResourceUploadDefinition', - 'ServiceRegistryInstance', - 'ServiceRegistryProperties', - 'ServiceRegistryResource', - 'ServiceRegistryResourceCollection', - 'ServiceRegistryResourceRequests', - 'ServiceResource', - 'ServiceResourceList', - 'ServiceSpecification', - 'Sku', - 'SkuCapacity', - 'SourceUploadedUserSourceInfo', - 'SsoProperties', - 'StackProperties', - 'StorageAccount', - 'StorageProperties', - 'StorageResource', - 'StorageResourceCollection', - 'SupportedBuildpackResource', - 'SupportedBuildpackResourceProperties', - 'SupportedBuildpacksCollection', - 'SupportedRuntimeVersion', - 'SupportedStackResource', - 'SupportedStackResourceProperties', - 'SupportedStacksCollection', - 'SystemData', - 'TemporaryDisk', - 'TestKeys', - 'TrackedResource', - 'TriggeredBuildResult', - 'UploadedUserSourceInfo', - 'UserAssignedManagedIdentity', - 'UserSourceInfo', - 'ValidationMessages', - 'ActionType', - 'ApiPortalProvisioningState', - 'AppResourceProvisioningState', - 'BindingType', - 'BuildProvisioningState', - 'BuildResultProvisioningState', - 'BuildServiceProvisioningState', - 'BuilderProvisioningState', - 'BuildpackBindingProvisioningState', - 'ConfigServerState', - 'ConfigurationServiceProvisioningState', - 'CreatedByType', - 'DeploymentResourceProvisioningState', - 'DeploymentResourceStatus', - 'GatewayProvisioningState', - 'KPackBuildStageProvisioningState', - 'LastModifiedByType', - 'ManagedIdentityType', - 'MonitoringSettingState', - 'PowerState', - 'ProvisioningState', - 'ResourceSkuRestrictionsReasonCode', - 'ResourceSkuRestrictionsType', - 'ServiceRegistryProvisioningState', - 'SkuScaleType', - 'StorageType', - 'SupportedRuntimePlatform', - 'SupportedRuntimeValue', - 'TestKeyType', - 'TrafficDirection', - 'Type', + "ActiveDeploymentCollection", + "ApiPortalCustomDomainProperties", + "ApiPortalCustomDomainResource", + "ApiPortalCustomDomainResourceCollection", + "ApiPortalInstance", + "ApiPortalProperties", + "ApiPortalResource", + "ApiPortalResourceCollection", + "ApiPortalResourceRequests", + "AppResource", + "AppResourceCollection", + "AppResourceProperties", + "ApplicationInsightsAgentVersions", + "AvailableOperations", + "AvailableRuntimeVersions", + "AzureFileVolume", + "BindingResource", + "BindingResourceCollection", + "BindingResourceProperties", + "Build", + "BuildCollection", + "BuildProperties", + "BuildResult", + "BuildResultCollection", + "BuildResultLog", + "BuildResultProperties", + "BuildResultUserSourceInfo", + "BuildService", + "BuildServiceAgentPoolProperties", + "BuildServiceAgentPoolResource", + "BuildServiceAgentPoolResourceCollection", + "BuildServiceAgentPoolSizeProperties", + "BuildServiceCollection", + "BuildServiceProperties", + "BuildServicePropertiesResourceRequests", + "BuildStageProperties", + "BuilderProperties", + "BuilderResource", + "BuilderResourceCollection", + "BuildpackBindingLaunchProperties", + "BuildpackBindingProperties", + "BuildpackBindingResource", + "BuildpackBindingResourceCollection", + "BuildpackProperties", + "BuildpacksGroupProperties", + "CertificateProperties", + "CertificateResource", + "CertificateResourceCollection", + "CloudErrorBody", + "ClusterResourceProperties", + "ConfigServerGitProperty", + "ConfigServerProperties", + "ConfigServerResource", + "ConfigServerSettings", + "ConfigServerSettingsErrorRecord", + "ConfigServerSettingsValidateResult", + "ConfigurationServiceGitProperty", + "ConfigurationServiceGitPropertyValidateResult", + "ConfigurationServiceGitRepository", + "ConfigurationServiceInstance", + "ConfigurationServiceProperties", + "ConfigurationServiceResource", + "ConfigurationServiceResourceCollection", + "ConfigurationServiceResourceRequests", + "ConfigurationServiceSettings", + "ConfigurationServiceSettingsValidateResult", + "ContainerProbeSettings", + "ContentCertificateProperties", + "CustomContainer", + "CustomContainerUserSourceInfo", + "CustomDomainProperties", + "CustomDomainResource", + "CustomDomainResourceCollection", + "CustomDomainValidatePayload", + "CustomDomainValidateResult", + "CustomPersistentDiskProperties", + "CustomPersistentDiskResource", + "DeploymentInstance", + "DeploymentResource", + "DeploymentResourceCollection", + "DeploymentResourceProperties", + "DeploymentSettings", + "DiagnosticParameters", + "Error", + "GatewayApiMetadataProperties", + "GatewayApiRoute", + "GatewayCorsProperties", + "GatewayCustomDomainProperties", + "GatewayCustomDomainResource", + "GatewayCustomDomainResourceCollection", + "GatewayInstance", + "GatewayOperatorProperties", + "GatewayOperatorResourceRequests", + "GatewayProperties", + "GatewayResource", + "GatewayResourceCollection", + "GatewayResourceRequests", + "GatewayRouteConfigProperties", + "GatewayRouteConfigResource", + "GatewayRouteConfigResourceCollection", + "GitPatternRepository", + "ImageRegistryCredential", + "JarUploadedUserSourceInfo", + "KeyVaultCertificateProperties", + "LoadedCertificate", + "LogFileUrlResponse", + "LogSpecification", + "ManagedIdentityProperties", + "MetricDimension", + "MetricSpecification", + "MonitoringSettingProperties", + "MonitoringSettingResource", + "NameAvailability", + "NameAvailabilityParameters", + "NetCoreZipUploadedUserSourceInfo", + "NetworkProfile", + "NetworkProfileOutboundIPs", + "OperationDetail", + "OperationDisplay", + "OperationProperties", + "PersistentDisk", + "ProxyResource", + "RegenerateTestKeyRequestPayload", + "RequiredTraffic", + "Resource", + "ResourceRequests", + "ResourceSku", + "ResourceSkuCapabilities", + "ResourceSkuCollection", + "ResourceSkuLocationInfo", + "ResourceSkuRestrictionInfo", + "ResourceSkuRestrictions", + "ResourceSkuZoneDetails", + "ResourceUploadDefinition", + "ServiceRegistryInstance", + "ServiceRegistryProperties", + "ServiceRegistryResource", + "ServiceRegistryResourceCollection", + "ServiceRegistryResourceRequests", + "ServiceResource", + "ServiceResourceList", + "ServiceSpecification", + "Sku", + "SkuCapacity", + "SourceUploadedUserSourceInfo", + "SsoProperties", + "StackProperties", + "StorageAccount", + "StorageProperties", + "StorageResource", + "StorageResourceCollection", + "SupportedBuildpackResource", + "SupportedBuildpackResourceProperties", + "SupportedBuildpacksCollection", + "SupportedRuntimeVersion", + "SupportedStackResource", + "SupportedStackResourceProperties", + "SupportedStacksCollection", + "SystemData", + "TemporaryDisk", + "TestKeys", + "TrackedResource", + "TriggeredBuildResult", + "UploadedUserSourceInfo", + "UserAssignedManagedIdentity", + "UserSourceInfo", + "ValidationMessages", + "ActionType", + "ApiPortalProvisioningState", + "AppResourceProvisioningState", + "BindingType", + "BuildProvisioningState", + "BuildResultProvisioningState", + "BuildServiceProvisioningState", + "BuilderProvisioningState", + "BuildpackBindingProvisioningState", + "ConfigServerState", + "ConfigurationServiceProvisioningState", + "CreatedByType", + "DeploymentResourceProvisioningState", + "DeploymentResourceStatus", + "GatewayProvisioningState", + "KPackBuildStageProvisioningState", + "LastModifiedByType", + "ManagedIdentityType", + "MonitoringSettingState", + "PowerState", + "ProvisioningState", + "ResourceSkuRestrictionsReasonCode", + "ResourceSkuRestrictionsType", + "ServiceRegistryProvisioningState", + "SkuScaleType", + "StorageType", + "SupportedRuntimePlatform", + "SupportedRuntimeValue", + "TestKeyType", + "TrafficDirection", + "Type", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/_app_platform_management_client_enums.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/_app_platform_management_client_enums.py index b10f39b3966c..835b540defc9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/_app_platform_management_client_enums.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/_app_platform_management_client_enums.py @@ -7,19 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - """ +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" INTERNAL = "Internal" -class ApiPortalProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the API portal. - """ + +class ApiPortalProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the API portal.""" CREATING = "Creating" UPDATING = "Updating" @@ -27,9 +25,9 @@ class ApiPortalProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, En FAILED = "Failed" DELETING = "Deleting" -class AppResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the App - """ + +class AppResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the App.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -37,9 +35,9 @@ class AppResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, UPDATING = "Updating" DELETING = "Deleting" -class BindingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Buildpack Binding Type - """ + +class BindingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Buildpack Binding Type.""" APPLICATION_INSIGHTS = "ApplicationInsights" APACHE_SKY_WALKING = "ApacheSkyWalking" @@ -48,9 +46,9 @@ class BindingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NEW_RELIC = "NewRelic" ELASTIC_APM = "ElasticAPM" -class BuilderProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Builder provision status. - """ + +class BuilderProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Builder provision status.""" CREATING = "Creating" UPDATING = "Updating" @@ -58,9 +56,9 @@ class BuilderProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" DELETING = "Deleting" -class BuildpackBindingProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Buildpack Binding. - """ + +class BuildpackBindingProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Buildpack Binding.""" CREATING = "Creating" UPDATING = "Updating" @@ -68,9 +66,9 @@ class BuildpackBindingProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, FAILED = "Failed" DELETING = "Deleting" -class BuildProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the KPack build result - """ + +class BuildProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" CREATING = "Creating" UPDATING = "Updating" @@ -78,9 +76,9 @@ class BuildProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) FAILED = "Failed" DELETING = "Deleting" -class BuildResultProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the KPack build result - """ + +class BuildResultProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" QUEUING = "Queuing" BUILDING = "Building" @@ -88,9 +86,9 @@ class BuildResultProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, FAILED = "Failed" DELETING = "Deleting" -class BuildServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the KPack build result - """ + +class BuildServiceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" CREATING = "Creating" UPDATING = "Updating" @@ -98,9 +96,9 @@ class BuildServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, FAILED = "Failed" DELETING = "Deleting" -class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the config server. - """ + +class ConfigServerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the config server.""" NOT_AVAILABLE = "NotAvailable" DELETED = "Deleted" @@ -108,9 +106,9 @@ class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ConfigurationServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Application Configuration Service. - """ + +class ConfigurationServiceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Application Configuration Service.""" CREATING = "Creating" UPDATING = "Updating" @@ -118,34 +116,34 @@ class ConfigurationServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMe FAILED = "Failed" DELETING = "Deleting" -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 DeploymentResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Deployment - """ + +class DeploymentResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Deployment.""" CREATING = "Creating" UPDATING = "Updating" SUCCEEDED = "Succeeded" FAILED = "Failed" -class DeploymentResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of the Deployment - """ + +class DeploymentResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the Deployment.""" STOPPED = "Stopped" RUNNING = "Running" -class GatewayProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Spring Cloud Gateway. - """ + +class GatewayProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Spring Cloud Gateway.""" CREATING = "Creating" UPDATING = "Updating" @@ -153,52 +151,52 @@ class GatewayProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" DELETING = "Deleting" -class KPackBuildStageProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of this build stage resource. - """ + +class KPackBuildStageProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of this build stage resource.""" NOT_STARTED = "NotStarted" RUNNING = "Running" SUCCEEDED = "Succeeded" FAILED = "Failed" -class LastModifiedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that last modified the resource. - """ + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class ManagedIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the managed identity - """ + +class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the managed identity.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class MonitoringSettingState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Monitoring Setting. - """ + +class MonitoringSettingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Monitoring Setting.""" NOT_AVAILABLE = "NotAvailable" FAILED = "Failed" SUCCEEDED = "Succeeded" UPDATING = "Updating" -class PowerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Power state of the Service - """ + +class PowerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Power state of the Service.""" RUNNING = "Running" STOPPED = "Stopped" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Service - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Service.""" CREATING = "Creating" UPDATING = "Updating" @@ -212,24 +210,25 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MOVED = "Moved" MOVE_FAILED = "MoveFailed" -class ResourceSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription' + 'NotAvailableForSubscription'. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ResourceSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets the type of restrictions. Possible values include: 'Location', 'Zone' - """ + +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the type of restrictions. Possible values include: 'Location', 'Zone'.""" LOCATION = "Location" ZONE = "Zone" -class ServiceRegistryProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Service Registry. - """ + +class ServiceRegistryProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Service Registry.""" CREATING = "Creating" UPDATING = "Updating" @@ -237,52 +236,52 @@ class ServiceRegistryProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, s FAILED = "Failed" DELETING = "Deleting" -class SkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets or sets the type of the scale. - """ + +class SkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type of the scale.""" NONE = "None" MANUAL = "Manual" AUTOMATIC = "Automatic" -class StorageType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the storage. - """ + +class StorageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the storage.""" STORAGE_ACCOUNT = "StorageAccount" -class SupportedRuntimePlatform(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The platform of this runtime version (possible values: "Java" or ".NET"). - """ + +class SupportedRuntimePlatform(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The platform of this runtime version (possible values: "Java" or ".NET").""" JAVA = "Java" _NET_CORE = ".NET Core" -class SupportedRuntimeValue(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The raw value which could be passed to deployment CRUD operations. - """ + +class SupportedRuntimeValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The raw value which could be passed to deployment CRUD operations.""" JAVA8 = "Java_8" JAVA11 = "Java_11" JAVA17 = "Java_17" NET_CORE31 = "NetCore_31" -class TestKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the test key - """ + +class TestKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the test key.""" PRIMARY = "Primary" SECONDARY = "Secondary" -class TrafficDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The direction of required traffic - """ + +class TrafficDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The direction of required traffic.""" INBOUND = "Inbound" OUTBOUND = "Outbound" -class Type(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the underlying resource to mount as a persistent disk. - """ + +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the underlying resource to mount as a persistent disk.""" AZURE_FILE_VOLUME = "AzureFileVolume" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/_models_py3.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/_models_py3.py index 94ce69f13398..95d753792913 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/_models_py3.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,14 +8,23 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._app_platform_management_client_enums import * +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ActiveDeploymentCollection(msrest.serialization.Model): + +class ActiveDeploymentCollection(_serialization.Model): """Object that includes an array of Deployment resource name and set them as active. :ivar active_deployment_names: Collection of Deployment name. @@ -22,24 +32,19 @@ class ActiveDeploymentCollection(msrest.serialization.Model): """ _attribute_map = { - 'active_deployment_names': {'key': 'activeDeploymentNames', 'type': '[str]'}, + "active_deployment_names": {"key": "activeDeploymentNames", "type": "[str]"}, } - def __init__( - self, - *, - active_deployment_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, active_deployment_names: Optional[List[str]] = None, **kwargs): """ :keyword active_deployment_names: Collection of Deployment name. :paramtype active_deployment_names: list[str] """ - super(ActiveDeploymentCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.active_deployment_names = active_deployment_names -class ApiPortalCustomDomainProperties(msrest.serialization.Model): +class ApiPortalCustomDomainProperties(_serialization.Model): """The properties of custom domain for API portal. :ivar thumbprint: The thumbprint of bound certificate. @@ -47,24 +52,19 @@ class ApiPortalCustomDomainProperties(msrest.serialization.Model): """ _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, + "thumbprint": {"key": "thumbprint", "type": "str"}, } - def __init__( - self, - *, - thumbprint: Optional[str] = None, - **kwargs - ): + def __init__(self, *, thumbprint: Optional[str] = None, **kwargs): """ :keyword thumbprint: The thumbprint of bound certificate. :paramtype thumbprint: str """ - super(ApiPortalCustomDomainProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = thumbprint -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The core properties of ARM resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -80,26 +80,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 @@ -122,26 +118,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 ApiPortalCustomDomainResource(ProxyResource): @@ -163,36 +155,31 @@ class ApiPortalCustomDomainResource(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': 'ApiPortalCustomDomainProperties'}, + "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": "ApiPortalCustomDomainProperties"}, } - def __init__( - self, - *, - properties: Optional["ApiPortalCustomDomainProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ApiPortalCustomDomainProperties"] = None, **kwargs): """ :keyword properties: The properties of custom domain for API portal. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainProperties """ - super(ApiPortalCustomDomainResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ApiPortalCustomDomainResourceCollection(msrest.serialization.Model): +class ApiPortalCustomDomainResourceCollection(_serialization.Model): """Object that includes an array of API portal custom domain resources and a possible link for next set. :ivar value: Collection of API portal custom domain resources. @@ -204,14 +191,14 @@ class ApiPortalCustomDomainResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiPortalCustomDomainResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ApiPortalCustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ApiPortalCustomDomainResource"]] = None, + value: Optional[List["_models.ApiPortalCustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -223,12 +210,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ApiPortalCustomDomainResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ApiPortalInstance(msrest.serialization.Model): +class ApiPortalInstance(_serialization.Model): """Collection of instances belong to the API portal. Variables are only populated by the server, and will be ignored when sending a request. @@ -240,33 +227,29 @@ class ApiPortalInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiPortalInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class ApiPortalProperties(msrest.serialization.Model): +class ApiPortalProperties(_serialization.Model): """API portal properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the API portal. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the API portal. Known values are: "Creating", "Updating", + "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalProvisioningState :ivar public: Indicates whether the API portal exposes endpoint. @@ -289,32 +272,32 @@ class ApiPortalProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'url': {'readonly': True}, - 'resource_requests': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "url": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'public': {'key': 'public', 'type': 'bool'}, - 'url': {'key': 'url', 'type': 'str'}, - 'https_only': {'key': 'httpsOnly', 'type': 'bool'}, - 'gateway_ids': {'key': 'gatewayIds', 'type': '[str]'}, - 'source_urls': {'key': 'sourceUrls', 'type': '[str]'}, - 'sso_properties': {'key': 'ssoProperties', 'type': 'SsoProperties'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'ApiPortalResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[ApiPortalInstance]'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "gateway_ids": {"key": "gatewayIds", "type": "[str]"}, + "source_urls": {"key": "sourceUrls", "type": "[str]"}, + "sso_properties": {"key": "ssoProperties", "type": "SsoProperties"}, + "resource_requests": {"key": "resourceRequests", "type": "ApiPortalResourceRequests"}, + "instances": {"key": "instances", "type": "[ApiPortalInstance]"}, } def __init__( self, *, - public: Optional[bool] = False, - https_only: Optional[bool] = False, + public: bool = False, + https_only: bool = False, gateway_ids: Optional[List[str]] = None, source_urls: Optional[List[str]] = None, - sso_properties: Optional["SsoProperties"] = None, + sso_properties: Optional["_models.SsoProperties"] = None, **kwargs ): """ @@ -329,7 +312,7 @@ def __init__( :keyword sso_properties: Single sign-on related configuration. :paramtype sso_properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.SsoProperties """ - super(ApiPortalProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.public = public self.url = None @@ -361,26 +344,26 @@ class ApiPortalResource(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': 'ApiPortalProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "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": "ApiPortalProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( self, *, - properties: Optional["ApiPortalProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.ApiPortalProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -389,12 +372,12 @@ def __init__( :keyword sku: Sku of the API portal resource. :paramtype sku: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Sku """ - super(ApiPortalResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.sku = sku -class ApiPortalResourceCollection(msrest.serialization.Model): +class ApiPortalResourceCollection(_serialization.Model): """Object that includes an array of API portal resources and a possible link for next set. :ivar value: Collection of API portal resources. @@ -405,16 +388,12 @@ class ApiPortalResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiPortalResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ApiPortalResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ApiPortalResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ApiPortalResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of API portal resources. @@ -423,12 +402,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ApiPortalResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ApiPortalResourceRequests(msrest.serialization.Model): +class ApiPortalResourceRequests(_serialization.Model): """Resource requests of the API portal. Variables are only populated by the server, and will be ignored when sending a request. @@ -440,27 +419,23 @@ class ApiPortalResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiPortalResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None -class ApplicationInsightsAgentVersions(msrest.serialization.Model): +class ApplicationInsightsAgentVersions(_serialization.Model): """Application Insights agent versions properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -470,20 +445,16 @@ class ApplicationInsightsAgentVersions(msrest.serialization.Model): """ _validation = { - 'java': {'readonly': True}, + "java": {"readonly": True}, } _attribute_map = { - 'java': {'key': 'java', 'type': 'str'}, + "java": {"key": "java", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApplicationInsightsAgentVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.java = None @@ -509,27 +480,27 @@ class AppResource(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': 'AppResourceProperties'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentityProperties'}, - 'location': {'key': 'location', 'type': 'str'}, + "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": "AppResourceProperties"}, + "identity": {"key": "identity", "type": "ManagedIdentityProperties"}, + "location": {"key": "location", "type": "str"}, } def __init__( self, *, - properties: Optional["AppResourceProperties"] = None, - identity: Optional["ManagedIdentityProperties"] = None, + properties: Optional["_models.AppResourceProperties"] = None, + identity: Optional["_models.ManagedIdentityProperties"] = None, location: Optional[str] = None, **kwargs ): @@ -543,13 +514,13 @@ def __init__( resource. :paramtype location: str """ - super(AppResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.identity = identity self.location = location -class AppResourceCollection(msrest.serialization.Model): +class AppResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of App resources. @@ -560,16 +531,12 @@ class AppResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AppResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AppResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["AppResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.AppResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of App resources. @@ -578,12 +545,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(AppResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class AppResourceProperties(msrest.serialization.Model): +class AppResourceProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """App resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -593,9 +560,9 @@ class AppResourceProperties(msrest.serialization.Model): :ivar url: URL of the App. :vartype url: str :ivar addon_configs: Collection of addons. - :vartype addon_configs: dict[str, dict[str, any]] - :ivar provisioning_state: Provisioning state of the App. Possible values include: "Succeeded", - "Failed", "Creating", "Updating", "Deleting". + :vartype addon_configs: dict[str, dict[str, JSON]] + :ivar provisioning_state: Provisioning state of the App. Known values are: "Succeeded", + "Failed", "Creating", "Updating", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResourceProvisioningState :ivar fqdn: Fully qualified dns Name. @@ -617,43 +584,43 @@ class AppResourceProperties(msrest.serialization.Model): """ _validation = { - 'url': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "url": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'public': {'key': 'public', 'type': 'bool'}, - 'url': {'key': 'url', 'type': 'str'}, - 'addon_configs': {'key': 'addonConfigs', 'type': '{{object}}'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'fqdn': {'key': 'fqdn', 'type': 'str'}, - 'https_only': {'key': 'httpsOnly', 'type': 'bool'}, - 'temporary_disk': {'key': 'temporaryDisk', 'type': 'TemporaryDisk'}, - 'persistent_disk': {'key': 'persistentDisk', 'type': 'PersistentDisk'}, - 'custom_persistent_disks': {'key': 'customPersistentDisks', 'type': '[CustomPersistentDiskResource]'}, - 'enable_end_to_end_tls': {'key': 'enableEndToEndTLS', 'type': 'bool'}, - 'loaded_certificates': {'key': 'loadedCertificates', 'type': '[LoadedCertificate]'}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "addon_configs": {"key": "addonConfigs", "type": "{{object}}"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "fqdn": {"key": "fqdn", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "temporary_disk": {"key": "temporaryDisk", "type": "TemporaryDisk"}, + "persistent_disk": {"key": "persistentDisk", "type": "PersistentDisk"}, + "custom_persistent_disks": {"key": "customPersistentDisks", "type": "[CustomPersistentDiskResource]"}, + "enable_end_to_end_tls": {"key": "enableEndToEndTLS", "type": "bool"}, + "loaded_certificates": {"key": "loadedCertificates", "type": "[LoadedCertificate]"}, } def __init__( self, *, public: Optional[bool] = None, - addon_configs: Optional[Dict[str, Dict[str, Any]]] = None, + addon_configs: Optional[Dict[str, Dict[str, JSON]]] = None, fqdn: Optional[str] = None, - https_only: Optional[bool] = False, - temporary_disk: Optional["TemporaryDisk"] = None, - persistent_disk: Optional["PersistentDisk"] = None, - custom_persistent_disks: Optional[List["CustomPersistentDiskResource"]] = None, - enable_end_to_end_tls: Optional[bool] = False, - loaded_certificates: Optional[List["LoadedCertificate"]] = None, + https_only: bool = False, + temporary_disk: Optional["_models.TemporaryDisk"] = None, + persistent_disk: Optional["_models.PersistentDisk"] = None, + custom_persistent_disks: Optional[List["_models.CustomPersistentDiskResource"]] = None, + enable_end_to_end_tls: bool = False, + loaded_certificates: Optional[List["_models.LoadedCertificate"]] = None, **kwargs ): """ :keyword public: Indicates whether the App exposes public endpoint. :paramtype public: bool :keyword addon_configs: Collection of addons. - :paramtype addon_configs: dict[str, dict[str, any]] + :paramtype addon_configs: dict[str, dict[str, JSON]] :keyword fqdn: Fully qualified dns Name. :paramtype fqdn: str :keyword https_only: Indicate if only https is allowed. @@ -671,7 +638,7 @@ def __init__( :paramtype loaded_certificates: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.LoadedCertificate] """ - super(AppResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.public = public self.url = None self.addon_configs = addon_configs @@ -685,7 +652,7 @@ def __init__( self.loaded_certificates = loaded_certificates -class AvailableOperations(msrest.serialization.Model): +class AvailableOperations(_serialization.Model): """Available operations of the service. :ivar value: Collection of available operation details. @@ -696,16 +663,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. @@ -714,12 +677,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 AvailableRuntimeVersions(msrest.serialization.Model): +class AvailableRuntimeVersions(_serialization.Model): """AvailableRuntimeVersions. Variables are only populated by the server, and will be ignored when sending a request. @@ -730,35 +693,31 @@ class AvailableRuntimeVersions(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedRuntimeVersion]'}, + "value": {"key": "value", "type": "[SupportedRuntimeVersion]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AvailableRuntimeVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class CustomPersistentDiskProperties(msrest.serialization.Model): +class CustomPersistentDiskProperties(_serialization.Model): """Custom persistent disk resource payload. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureFileVolume. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureFileVolume All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the underlying resource to mount as a persistent - disk.Constant filled by server. Possible values include: "AzureFileVolume". + :ivar type: The type of the underlying resource to mount as a persistent disk. Required. + "AzureFileVolume" :vartype type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.Type - :ivar mount_path: Required. The mount path of the persistent disk. + :ivar mount_path: The mount path of the persistent disk. Required. :vartype mount_path: str :ivar read_only: Indicates whether the persistent disk is a readOnly one. :vartype read_only: bool @@ -767,38 +726,31 @@ class CustomPersistentDiskProperties(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, - 'mount_path': {'required': True}, + "type": {"required": True}, + "mount_path": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, - 'read_only': {'key': 'readOnly', 'type': 'bool'}, - 'mount_options': {'key': 'mountOptions', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "mount_path": {"key": "mountPath", "type": "str"}, + "read_only": {"key": "readOnly", "type": "bool"}, + "mount_options": {"key": "mountOptions", "type": "[str]"}, } - _subtype_map = { - 'type': {'AzureFileVolume': 'AzureFileVolume'} - } + _subtype_map = {"type": {"AzureFileVolume": "AzureFileVolume"}} def __init__( - self, - *, - mount_path: str, - read_only: Optional[bool] = None, - mount_options: Optional[List[str]] = None, - **kwargs + self, *, mount_path: str, read_only: Optional[bool] = None, mount_options: Optional[List[str]] = None, **kwargs ): """ - :keyword mount_path: Required. The mount path of the persistent disk. + :keyword mount_path: The mount path of the persistent disk. Required. :paramtype mount_path: str :keyword read_only: Indicates whether the persistent disk is a readOnly one. :paramtype read_only: bool :keyword mount_options: These are the mount options for a persistent disk. :paramtype mount_options: list[str] """ - super(CustomPersistentDiskProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None # type: Optional[str] self.mount_path = mount_path self.read_only = read_only @@ -810,31 +762,31 @@ class AzureFileVolume(CustomPersistentDiskProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the underlying resource to mount as a persistent - disk.Constant filled by server. Possible values include: "AzureFileVolume". + :ivar type: The type of the underlying resource to mount as a persistent disk. Required. + "AzureFileVolume" :vartype type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.Type - :ivar mount_path: Required. The mount path of the persistent disk. + :ivar mount_path: The mount path of the persistent disk. Required. :vartype mount_path: str :ivar read_only: Indicates whether the persistent disk is a readOnly one. :vartype read_only: bool :ivar mount_options: These are the mount options for a persistent disk. :vartype mount_options: list[str] - :ivar share_name: Required. The share name of the Azure File share. + :ivar share_name: The share name of the Azure File share. Required. :vartype share_name: str """ _validation = { - 'type': {'required': True}, - 'mount_path': {'required': True}, - 'share_name': {'required': True}, + "type": {"required": True}, + "mount_path": {"required": True}, + "share_name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, - 'read_only': {'key': 'readOnly', 'type': 'bool'}, - 'mount_options': {'key': 'mountOptions', 'type': '[str]'}, - 'share_name': {'key': 'shareName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "mount_path": {"key": "mountPath", "type": "str"}, + "read_only": {"key": "readOnly", "type": "bool"}, + "mount_options": {"key": "mountOptions", "type": "[str]"}, + "share_name": {"key": "shareName", "type": "str"}, } def __init__( @@ -847,17 +799,17 @@ def __init__( **kwargs ): """ - :keyword mount_path: Required. The mount path of the persistent disk. + :keyword mount_path: The mount path of the persistent disk. Required. :paramtype mount_path: str :keyword read_only: Indicates whether the persistent disk is a readOnly one. :paramtype read_only: bool :keyword mount_options: These are the mount options for a persistent disk. :paramtype mount_options: list[str] - :keyword share_name: Required. The share name of the Azure File share. + :keyword share_name: The share name of the Azure File share. Required. :paramtype share_name: str """ - super(AzureFileVolume, self).__init__(mount_path=mount_path, read_only=read_only, mount_options=mount_options, **kwargs) - self.type = 'AzureFileVolume' # type: str + super().__init__(mount_path=mount_path, read_only=read_only, mount_options=mount_options, **kwargs) + self.type = "AzureFileVolume" # type: str self.share_name = share_name @@ -880,36 +832,31 @@ class BindingResource(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': 'BindingResourceProperties'}, + "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": "BindingResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["BindingResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BindingResourceProperties"] = None, **kwargs): """ :keyword properties: Properties of the Binding resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResourceProperties """ - super(BindingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BindingResourceCollection(msrest.serialization.Model): +class BindingResourceCollection(_serialization.Model): """Object that includes an array of Binding resources and a possible link for next set. :ivar value: Collection of Binding resources. @@ -920,16 +867,12 @@ class BindingResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BindingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BindingResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BindingResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Binding resources. @@ -938,12 +881,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BindingResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BindingResourceProperties(msrest.serialization.Model): +class BindingResourceProperties(_serialization.Model): """Binding resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -957,7 +900,7 @@ class BindingResourceProperties(msrest.serialization.Model): :ivar key: The key of the bound resource. :vartype key: str :ivar binding_parameters: Binding parameters of the Binding resource. - :vartype binding_parameters: dict[str, any] + :vartype binding_parameters: dict[str, JSON] :ivar generated_properties: The generated Spring Boot property file for this binding. The secret will be deducted. :vartype generated_properties: str @@ -968,22 +911,22 @@ class BindingResourceProperties(msrest.serialization.Model): """ _validation = { - 'resource_name': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'generated_properties': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, + "resource_name": {"readonly": True}, + "resource_type": {"readonly": True}, + "generated_properties": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, } _attribute_map = { - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'binding_parameters': {'key': 'bindingParameters', 'type': '{object}'}, - 'generated_properties': {'key': 'generatedProperties', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'str'}, - 'updated_at': {'key': 'updatedAt', 'type': 'str'}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "binding_parameters": {"key": "bindingParameters", "type": "{object}"}, + "generated_properties": {"key": "generatedProperties", "type": "str"}, + "created_at": {"key": "createdAt", "type": "str"}, + "updated_at": {"key": "updatedAt", "type": "str"}, } def __init__( @@ -991,7 +934,7 @@ def __init__( *, resource_id: Optional[str] = None, key: Optional[str] = None, - binding_parameters: Optional[Dict[str, Any]] = None, + binding_parameters: Optional[Dict[str, JSON]] = None, **kwargs ): """ @@ -1000,9 +943,9 @@ def __init__( :keyword key: The key of the bound resource. :paramtype key: str :keyword binding_parameters: Binding parameters of the Binding resource. - :paramtype binding_parameters: dict[str, any] + :paramtype binding_parameters: dict[str, JSON] """ - super(BindingResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_name = None self.resource_type = None self.resource_id = resource_id @@ -1031,35 +974,30 @@ class Build(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': 'BuildProperties'}, + "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": "BuildProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildProperties"] = None, **kwargs): """ :keyword properties: Properties of the build resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildProperties """ - super(Build, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildCollection(msrest.serialization.Model): +class BuildCollection(_serialization.Model): """Object that includes an array of Build resources and a possible link for next set. :ivar value: Collection of Build resources. @@ -1070,17 +1008,11 @@ class BuildCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Build]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Build]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Build"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Build"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Collection of Build resources. :paramtype value: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.Build] @@ -1088,18 +1020,18 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuilderProperties(msrest.serialization.Model): +class BuilderProperties(_serialization.Model): """KPack Builder properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Builder provision status. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Builder provision status. Known values are: "Creating", "Updating", + "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderProvisioningState :ivar stack: Builder cluster stack property. @@ -1110,20 +1042,20 @@ class BuilderProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'stack': {'key': 'stack', 'type': 'StackProperties'}, - 'buildpack_groups': {'key': 'buildpackGroups', 'type': '[BuildpacksGroupProperties]'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "stack": {"key": "stack", "type": "StackProperties"}, + "buildpack_groups": {"key": "buildpackGroups", "type": "[BuildpacksGroupProperties]"}, } def __init__( self, *, - stack: Optional["StackProperties"] = None, - buildpack_groups: Optional[List["BuildpacksGroupProperties"]] = None, + stack: Optional["_models.StackProperties"] = None, + buildpack_groups: Optional[List["_models.BuildpacksGroupProperties"]] = None, **kwargs ): """ @@ -1133,7 +1065,7 @@ def __init__( :paramtype buildpack_groups: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpacksGroupProperties] """ - super(BuilderProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.stack = stack self.buildpack_groups = buildpack_groups @@ -1157,35 +1089,30 @@ class BuilderResource(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': 'BuilderProperties'}, + "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": "BuilderProperties"}, } - def __init__( - self, - *, - properties: Optional["BuilderProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuilderProperties"] = None, **kwargs): """ :keyword properties: Property of the Builder resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderProperties """ - super(BuilderResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuilderResourceCollection(msrest.serialization.Model): +class BuilderResourceCollection(_serialization.Model): """Object that includes an array of Builder resources and a possible link for next set. :ivar value: Collection of Builder resources. @@ -1196,16 +1123,12 @@ class BuilderResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuilderResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuilderResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BuilderResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BuilderResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Builder resources. @@ -1214,12 +1137,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuilderResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildpackBindingLaunchProperties(msrest.serialization.Model): +class BuildpackBindingLaunchProperties(_serialization.Model): """Buildpack Binding Launch Properties. :ivar properties: Non-sensitive properties for launchProperties. @@ -1229,16 +1152,12 @@ class BuildpackBindingLaunchProperties(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'secrets': {'key': 'secrets', 'type': '{str}'}, + "properties": {"key": "properties", "type": "{str}"}, + "secrets": {"key": "secrets", "type": "{str}"}, } def __init__( - self, - *, - properties: Optional[Dict[str, str]] = None, - secrets: Optional[Dict[str, str]] = None, - **kwargs + self, *, properties: Optional[Dict[str, str]] = None, secrets: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword properties: Non-sensitive properties for launchProperties. @@ -1246,21 +1165,21 @@ def __init__( :keyword secrets: Sensitive properties for launchProperties. :paramtype secrets: dict[str, str] """ - super(BuildpackBindingLaunchProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.secrets = secrets -class BuildpackBindingProperties(msrest.serialization.Model): +class BuildpackBindingProperties(_serialization.Model): """Properties of a buildpack binding. Variables are only populated by the server, and will be ignored when sending a request. - :ivar binding_type: Buildpack Binding Type. Possible values include: "ApplicationInsights", - "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", "ElasticAPM". + :ivar binding_type: Buildpack Binding Type. Known values are: "ApplicationInsights", + "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", and "ElasticAPM". :vartype binding_type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingType - :ivar provisioning_state: State of the Buildpack Binding. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Buildpack Binding. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingProvisioningState :ivar launch_properties: The object describes the buildpack binding launch properties. @@ -1269,31 +1188,31 @@ class BuildpackBindingProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'binding_type': {'key': 'bindingType', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'launch_properties': {'key': 'launchProperties', 'type': 'BuildpackBindingLaunchProperties'}, + "binding_type": {"key": "bindingType", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "launch_properties": {"key": "launchProperties", "type": "BuildpackBindingLaunchProperties"}, } def __init__( self, *, - binding_type: Optional[Union[str, "BindingType"]] = None, - launch_properties: Optional["BuildpackBindingLaunchProperties"] = None, + binding_type: Optional[Union[str, "_models.BindingType"]] = None, + launch_properties: Optional["_models.BuildpackBindingLaunchProperties"] = None, **kwargs ): """ - :keyword binding_type: Buildpack Binding Type. Possible values include: "ApplicationInsights", - "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", "ElasticAPM". + :keyword binding_type: Buildpack Binding Type. Known values are: "ApplicationInsights", + "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", and "ElasticAPM". :paramtype binding_type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingType :keyword launch_properties: The object describes the buildpack binding launch properties. :paramtype launch_properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingLaunchProperties """ - super(BuildpackBindingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.binding_type = binding_type self.provisioning_state = None self.launch_properties = launch_properties @@ -1318,36 +1237,31 @@ class BuildpackBindingResource(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': 'BuildpackBindingProperties'}, + "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": "BuildpackBindingProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildpackBindingProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildpackBindingProperties"] = None, **kwargs): """ :keyword properties: Properties of a buildpack binding. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingProperties """ - super(BuildpackBindingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildpackBindingResourceCollection(msrest.serialization.Model): +class BuildpackBindingResourceCollection(_serialization.Model): """Object that includes an array of BuildpackBinding resources and a possible link for next set. :ivar value: Collection of BuildpackBinding resources. @@ -1359,14 +1273,14 @@ class BuildpackBindingResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildpackBindingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildpackBindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["BuildpackBindingResource"]] = None, + value: Optional[List["_models.BuildpackBindingResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1378,12 +1292,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildpackBindingResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildpackProperties(msrest.serialization.Model): +class BuildpackProperties(_serialization.Model): """Buildpack properties payload. :ivar id: Id of the buildpack. @@ -1391,24 +1305,19 @@ class BuildpackProperties(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Id of the buildpack. :paramtype id: str """ - super(BuildpackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class BuildpacksGroupProperties(msrest.serialization.Model): +class BuildpacksGroupProperties(_serialization.Model): """Buildpack group properties of the Builder. :ivar name: Buildpack group name. @@ -1419,16 +1328,12 @@ class BuildpacksGroupProperties(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'buildpacks': {'key': 'buildpacks', 'type': '[BuildpackProperties]'}, + "name": {"key": "name", "type": "str"}, + "buildpacks": {"key": "buildpacks", "type": "[BuildpackProperties]"}, } def __init__( - self, - *, - name: Optional[str] = None, - buildpacks: Optional[List["BuildpackProperties"]] = None, - **kwargs + self, *, name: Optional[str] = None, buildpacks: Optional[List["_models.BuildpackProperties"]] = None, **kwargs ): """ :keyword name: Buildpack group name. @@ -1437,12 +1342,12 @@ def __init__( :paramtype buildpacks: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackProperties] """ - super(BuildpacksGroupProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.buildpacks = buildpacks -class BuildProperties(msrest.serialization.Model): +class BuildProperties(_serialization.Model): """Build resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1453,8 +1358,8 @@ class BuildProperties(msrest.serialization.Model): :vartype builder: str :ivar agent_pool: The resource id of agent pool. :vartype agent_pool: str - :ivar provisioning_state: Provisioning state of the KPack build result. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildProvisioningState :ivar env: The environment variables for this build. @@ -1465,17 +1370,17 @@ class BuildProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'triggered_build_result': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "triggered_build_result": {"readonly": True}, } _attribute_map = { - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'builder': {'key': 'builder', 'type': 'str'}, - 'agent_pool': {'key': 'agentPool', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'env': {'key': 'env', 'type': '{str}'}, - 'triggered_build_result': {'key': 'triggeredBuildResult', 'type': 'TriggeredBuildResult'}, + "relative_path": {"key": "relativePath", "type": "str"}, + "builder": {"key": "builder", "type": "str"}, + "agent_pool": {"key": "agentPool", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "env": {"key": "env", "type": "{str}"}, + "triggered_build_result": {"key": "triggeredBuildResult", "type": "TriggeredBuildResult"}, } def __init__( @@ -1497,7 +1402,7 @@ def __init__( :keyword env: The environment variables for this build. :paramtype env: dict[str, str] """ - super(BuildProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.relative_path = relative_path self.builder = builder self.agent_pool = agent_pool @@ -1524,35 +1429,30 @@ class BuildResult(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': 'BuildResultProperties'}, + "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": "BuildResultProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildResultProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildResultProperties"] = None, **kwargs): """ :keyword properties: Properties of the build result resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildResultProperties """ - super(BuildResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildResultCollection(msrest.serialization.Model): +class BuildResultCollection(_serialization.Model): """Object that includes an array of Build result resources and a possible link for next set. :ivar value: Collection of Build result resources. @@ -1563,16 +1463,12 @@ class BuildResultCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildResult]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BuildResult"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BuildResult"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Build result resources. @@ -1581,12 +1477,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildResultCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildResultLog(msrest.serialization.Model): +class BuildResultLog(_serialization.Model): """Build result log resource properties payload. :ivar blob_url: The public download URL of this build result log. @@ -1594,32 +1490,27 @@ class BuildResultLog(msrest.serialization.Model): """ _attribute_map = { - 'blob_url': {'key': 'blobUrl', 'type': 'str'}, + "blob_url": {"key": "blobUrl", "type": "str"}, } - def __init__( - self, - *, - blob_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, blob_url: Optional[str] = None, **kwargs): """ :keyword blob_url: The public download URL of this build result log. :paramtype blob_url: str """ - super(BuildResultLog, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob_url = blob_url -class BuildResultProperties(msrest.serialization.Model): +class BuildResultProperties(_serialization.Model): """Build result resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. :ivar name: The name of this build result. :vartype name: str - :ivar provisioning_state: Provisioning state of the KPack build result. Possible values - include: "Queuing", "Building", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Queuing", "Building", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildResultProvisioningState :ivar build_pod_name: The build pod name which can be used to get the build log streaming. @@ -1631,75 +1522,68 @@ class BuildResultProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'build_stages': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "build_stages": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'build_pod_name': {'key': 'buildPodName', 'type': 'str'}, - 'build_stages': {'key': 'buildStages', 'type': '[BuildStageProperties]'}, + "name": {"key": "name", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "build_pod_name": {"key": "buildPodName", "type": "str"}, + "build_stages": {"key": "buildStages", "type": "[BuildStageProperties]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - build_pod_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, build_pod_name: Optional[str] = None, **kwargs): """ :keyword name: The name of this build result. :paramtype name: str :keyword build_pod_name: The build pod name which can be used to get the build log streaming. :paramtype build_pod_name: str """ - super(BuildResultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.provisioning_state = None self.build_pod_name = build_pod_name self.build_stages = None -class UserSourceInfo(msrest.serialization.Model): +class UserSourceInfo(_serialization.Model): """Source information for a deployment. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: BuildResultUserSourceInfo, CustomContainerUserSourceInfo, UploadedUserSourceInfo. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + BuildResultUserSourceInfo, CustomContainerUserSourceInfo, UploadedUserSourceInfo All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, } _subtype_map = { - 'type': {'BuildResult': 'BuildResultUserSourceInfo', 'Container': 'CustomContainerUserSourceInfo', 'UploadedUserSourceInfo': 'UploadedUserSourceInfo'} + "type": { + "BuildResult": "BuildResultUserSourceInfo", + "Container": "CustomContainerUserSourceInfo", + "UploadedUserSourceInfo": "UploadedUserSourceInfo", + } } - def __init__( - self, - *, - version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, version: Optional[str] = None, **kwargs): """ :keyword version: Version of the source. :paramtype version: str """ - super(UserSourceInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None # type: Optional[str] self.version = version @@ -1709,7 +1593,7 @@ class BuildResultUserSourceInfo(UserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -1719,22 +1603,16 @@ class BuildResultUserSourceInfo(UserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'build_result_id': {'key': 'buildResultId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "build_result_id": {"key": "buildResultId", "type": "str"}, } - def __init__( - self, - *, - version: Optional[str] = None, - build_result_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, version: Optional[str] = None, build_result_id: Optional[str] = None, **kwargs): """ :keyword version: Version of the source. :paramtype version: str @@ -1742,8 +1620,8 @@ def __init__( Spring instance. :paramtype build_result_id: str """ - super(BuildResultUserSourceInfo, self).__init__(version=version, **kwargs) - self.type = 'BuildResult' # type: str + super().__init__(version=version, **kwargs) + self.type = "BuildResult" # type: str self.build_result_id = build_result_id @@ -1765,36 +1643,31 @@ class BuildService(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': 'BuildServiceProperties'}, + "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": "BuildServiceProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildServiceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildServiceProperties"] = None, **kwargs): """ :keyword properties: Properties of the build resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceProperties """ - super(BuildService, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildServiceAgentPoolProperties(msrest.serialization.Model): +class BuildServiceAgentPoolProperties(_serialization.Model): """Build service agent pool properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1807,26 +1680,21 @@ class BuildServiceAgentPoolProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'pool_size': {'key': 'poolSize', 'type': 'BuildServiceAgentPoolSizeProperties'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "pool_size": {"key": "poolSize", "type": "BuildServiceAgentPoolSizeProperties"}, } - def __init__( - self, - *, - pool_size: Optional["BuildServiceAgentPoolSizeProperties"] = None, - **kwargs - ): + def __init__(self, *, pool_size: Optional["_models.BuildServiceAgentPoolSizeProperties"] = None, **kwargs): """ :keyword pool_size: build service agent pool size properties. :paramtype pool_size: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolSizeProperties """ - super(BuildServiceAgentPoolProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.pool_size = pool_size @@ -1850,36 +1718,31 @@ class BuildServiceAgentPoolResource(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': 'BuildServiceAgentPoolProperties'}, + "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": "BuildServiceAgentPoolProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildServiceAgentPoolProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildServiceAgentPoolProperties"] = None, **kwargs): """ :keyword properties: build service agent pool properties. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolProperties """ - super(BuildServiceAgentPoolResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildServiceAgentPoolResourceCollection(msrest.serialization.Model): +class BuildServiceAgentPoolResourceCollection(_serialization.Model): """Object that includes an array of build service agent pool resources and a possible link for next set. :ivar value: Collection of build service agent pool resource. @@ -1891,14 +1754,14 @@ class BuildServiceAgentPoolResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildServiceAgentPoolResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildServiceAgentPoolResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["BuildServiceAgentPoolResource"]] = None, + value: Optional[List["_models.BuildServiceAgentPoolResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1910,12 +1773,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildServiceAgentPoolResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildServiceAgentPoolSizeProperties(msrest.serialization.Model): +class BuildServiceAgentPoolSizeProperties(_serialization.Model): """Build service agent pool size properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1929,33 +1792,28 @@ class BuildServiceAgentPoolSizeProperties(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The name of build service agent pool size. :paramtype name: str """ - super(BuildServiceAgentPoolSizeProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.cpu = None self.memory = None -class BuildServiceCollection(msrest.serialization.Model): +class BuildServiceCollection(_serialization.Model): """Object that includes an array of Build service resources and a possible link for next set. :ivar value: Collection of Build service resources. @@ -1966,16 +1824,12 @@ class BuildServiceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildService]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildService]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BuildService"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BuildService"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Build service resources. @@ -1984,20 +1838,20 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildServiceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildServiceProperties(msrest.serialization.Model): +class BuildServiceProperties(_serialization.Model): """Build service resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. :ivar k_pack_version: The installed KPack version in this build service. :vartype k_pack_version: str - :ivar provisioning_state: Provisioning state of the KPack build result. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceProvisioningState :ivar resource_requests: The runtime resource configuration of this build service. @@ -2006,20 +1860,20 @@ class BuildServiceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'k_pack_version': {'key': 'kPackVersion', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'BuildServicePropertiesResourceRequests'}, + "k_pack_version": {"key": "kPackVersion", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "BuildServicePropertiesResourceRequests"}, } def __init__( self, *, k_pack_version: Optional[str] = None, - resource_requests: Optional["BuildServicePropertiesResourceRequests"] = None, + resource_requests: Optional["_models.BuildServicePropertiesResourceRequests"] = None, **kwargs ): """ @@ -2029,13 +1883,13 @@ def __init__( :paramtype resource_requests: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServicePropertiesResourceRequests """ - super(BuildServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.k_pack_version = k_pack_version self.provisioning_state = None self.resource_requests = resource_requests -class BuildServicePropertiesResourceRequests(msrest.serialization.Model): +class BuildServicePropertiesResourceRequests(_serialization.Model): """The runtime resource configuration of this build service. Variables are only populated by the server, and will be ignored when sending a request. @@ -2047,71 +1901,63 @@ class BuildServicePropertiesResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BuildServicePropertiesResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None -class BuildStageProperties(msrest.serialization.Model): +class BuildStageProperties(_serialization.Model): """The build stage (init-container and container) resources in build pod. Variables are only populated by the server, and will be ignored when sending a request. :ivar name: The name of this build stage resource. :vartype name: str - :ivar status: The provisioning state of this build stage resource. Possible values include: - "NotStarted", "Running", "Succeeded", "Failed". + :ivar status: The provisioning state of this build stage resource. Known values are: + "NotStarted", "Running", "Succeeded", and "Failed". :vartype status: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.KPackBuildStageProvisioningState """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BuildStageProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """Certificate resource payload. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ContentCertificateProperties, KeyVaultCertificateProperties. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContentCertificateProperties, KeyVaultCertificateProperties Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -2130,38 +1976,37 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, } _subtype_map = { - 'type': {'ContentCertificate': 'ContentCertificateProperties', 'KeyVaultCertificate': 'KeyVaultCertificateProperties'} + "type": { + "ContentCertificate": "ContentCertificateProperties", + "KeyVaultCertificate": "KeyVaultCertificateProperties", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificateProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None # type: Optional[str] self.thumbprint = None self.issuer = None @@ -2190,35 +2035,30 @@ class CertificateResource(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': 'CertificateProperties'}, + "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": "CertificateProperties"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: Properties of the certificate resource payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateProperties """ - super(CertificateResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CertificateResourceCollection(msrest.serialization.Model): +class CertificateResourceCollection(_serialization.Model): """Collection compose of certificate resources list and a possible link for next page. :ivar value: The certificate resources list. @@ -2228,16 +2068,12 @@ class CertificateResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CertificateResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CertificateResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CertificateResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The certificate resources list. @@ -2245,12 +2081,12 @@ def __init__( :keyword next_link: The link to next page of certificate list. :paramtype next_link: str """ - super(CertificateResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -2267,10 +2103,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -2279,7 +2115,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -2295,21 +2131,21 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class ClusterResourceProperties(msrest.serialization.Model): +class ClusterResourceProperties(_serialization.Model): """Service properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Provisioning state of the Service. Possible values include: - "Creating", "Updating", "Starting", "Stopping", "Deleting", "Deleted", "Succeeded", "Failed", - "Moving", "Moved", "MoveFailed". + :ivar provisioning_state: Provisioning state of the Service. Known values are: "Creating", + "Updating", "Starting", "Stopping", "Deleting", "Deleted", "Succeeded", "Failed", "Moving", + "Moved", and "MoveFailed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.ProvisioningState :ivar network_profile: Network profile of the Service. @@ -2318,7 +2154,7 @@ class ClusterResourceProperties(msrest.serialization.Model): :vartype version: int :ivar service_id: ServiceInstanceEntity GUID which uniquely identifies a created resource. :vartype service_id: str - :ivar power_state: Power state of the Service. Possible values include: "Running", "Stopped". + :ivar power_state: Power state of the Service. Known values are: "Running" and "Stopped". :vartype power_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.PowerState :ivar zone_redundant: :vartype zone_redundant: bool @@ -2327,29 +2163,25 @@ class ClusterResourceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'version': {'readonly': True}, - 'service_id': {'readonly': True}, - 'power_state': {'readonly': True}, - 'fqdn': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "service_id": {"readonly": True}, + "power_state": {"readonly": True}, + "fqdn": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'network_profile': {'key': 'networkProfile', 'type': 'NetworkProfile'}, - 'version': {'key': 'version', 'type': 'int'}, - 'service_id': {'key': 'serviceId', 'type': 'str'}, - 'power_state': {'key': 'powerState', 'type': 'str'}, - 'zone_redundant': {'key': 'zoneRedundant', 'type': 'bool'}, - 'fqdn': {'key': 'fqdn', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "network_profile": {"key": "networkProfile", "type": "NetworkProfile"}, + "version": {"key": "version", "type": "int"}, + "service_id": {"key": "serviceId", "type": "str"}, + "power_state": {"key": "powerState", "type": "str"}, + "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, + "fqdn": {"key": "fqdn", "type": "str"}, } def __init__( - self, - *, - network_profile: Optional["NetworkProfile"] = None, - zone_redundant: Optional[bool] = False, - **kwargs + self, *, network_profile: Optional["_models.NetworkProfile"] = None, zone_redundant: bool = False, **kwargs ): """ :keyword network_profile: Network profile of the Service. @@ -2357,7 +2189,7 @@ def __init__( :keyword zone_redundant: :paramtype zone_redundant: bool """ - super(ClusterResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.network_profile = network_profile self.version = None @@ -2367,7 +2199,7 @@ def __init__( self.fqdn = None -class ConfigServerGitProperty(msrest.serialization.Model): +class ConfigServerGitProperty(_serialization.Model): """Property of git. All required parameters must be populated in order to send to Azure. @@ -2375,7 +2207,7 @@ class ConfigServerGitProperty(msrest.serialization.Model): :ivar repositories: Repositories of git. :vartype repositories: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.GitPatternRepository] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -2396,27 +2228,27 @@ class ConfigServerGitProperty(msrest.serialization.Model): """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'repositories': {'key': 'repositories', 'type': '[GitPatternRepository]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "repositories": {"key": "repositories", "type": "[GitPatternRepository]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( self, *, uri: str, - repositories: Optional[List["GitPatternRepository"]] = None, + repositories: Optional[List["_models.GitPatternRepository"]] = None, label: Optional[str] = None, search_paths: Optional[List[str]] = None, username: Optional[str] = None, @@ -2431,7 +2263,7 @@ def __init__( :keyword repositories: Repositories of git. :paramtype repositories: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.GitPatternRepository] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -2450,7 +2282,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(ConfigServerGitProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.repositories = repositories self.uri = uri self.label = label @@ -2463,13 +2295,13 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ConfigServerProperties(msrest.serialization.Model): +class ConfigServerProperties(_serialization.Model): """Config server git properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the config server. Possible values include: "NotAvailable", - "Deleted", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the config server. Known values are: "NotAvailable", + "Deleted", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerState :ivar error: Error when apply config server settings. @@ -2479,20 +2311,20 @@ class ConfigServerProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'config_server': {'key': 'configServer', 'type': 'ConfigServerSettings'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "config_server": {"key": "configServer", "type": "ConfigServerSettings"}, } def __init__( self, *, - error: Optional["Error"] = None, - config_server: Optional["ConfigServerSettings"] = None, + error: Optional["_models.Error"] = None, + config_server: Optional["_models.ConfigServerSettings"] = None, **kwargs ): """ @@ -2502,7 +2334,7 @@ def __init__( :paramtype config_server: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerSettings """ - super(ConfigServerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.config_server = config_server @@ -2526,36 +2358,31 @@ class ConfigServerResource(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': 'ConfigServerProperties'}, + "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": "ConfigServerProperties"}, } - def __init__( - self, - *, - properties: Optional["ConfigServerProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ConfigServerProperties"] = None, **kwargs): """ :keyword properties: Properties of the Config Server resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerProperties """ - super(ConfigServerResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ConfigServerSettings(msrest.serialization.Model): +class ConfigServerSettings(_serialization.Model): """The settings of config server. :ivar git_property: Property of git environment. @@ -2564,25 +2391,20 @@ class ConfigServerSettings(msrest.serialization.Model): """ _attribute_map = { - 'git_property': {'key': 'gitProperty', 'type': 'ConfigServerGitProperty'}, + "git_property": {"key": "gitProperty", "type": "ConfigServerGitProperty"}, } - def __init__( - self, - *, - git_property: Optional["ConfigServerGitProperty"] = None, - **kwargs - ): + def __init__(self, *, git_property: Optional["_models.ConfigServerGitProperty"] = None, **kwargs): """ :keyword git_property: Property of git environment. :paramtype git_property: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerGitProperty """ - super(ConfigServerSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property = git_property -class ConfigServerSettingsErrorRecord(msrest.serialization.Model): +class ConfigServerSettingsErrorRecord(_serialization.Model): """Error record of the config server settings. :ivar name: The name of the config server settings error record. @@ -2594,18 +2416,13 @@ class ConfigServerSettingsErrorRecord(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'messages': {'key': 'messages', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, } def __init__( - self, - *, - name: Optional[str] = None, - uri: Optional[str] = None, - messages: Optional[List[str]] = None, - **kwargs + self, *, name: Optional[str] = None, uri: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs ): """ :keyword name: The name of the config server settings error record. @@ -2615,13 +2432,13 @@ def __init__( :keyword messages: The detail error messages of the record. :paramtype messages: list[str] """ - super(ConfigServerSettingsErrorRecord, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.uri = uri self.messages = messages -class ConfigServerSettingsValidateResult(msrest.serialization.Model): +class ConfigServerSettingsValidateResult(_serialization.Model): """Validation result for config server settings. :ivar is_valid: Indicate if the config server settings are valid. @@ -2632,15 +2449,15 @@ class ConfigServerSettingsValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'details': {'key': 'details', 'type': '[ConfigServerSettingsErrorRecord]'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "details": {"key": "details", "type": "[ConfigServerSettingsErrorRecord]"}, } def __init__( self, *, is_valid: Optional[bool] = None, - details: Optional[List["ConfigServerSettingsErrorRecord"]] = None, + details: Optional[List["_models.ConfigServerSettingsErrorRecord"]] = None, **kwargs ): """ @@ -2650,12 +2467,12 @@ def __init__( :paramtype details: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerSettingsErrorRecord] """ - super(ConfigServerSettingsValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.details = details -class ConfigurationServiceGitProperty(msrest.serialization.Model): +class ConfigurationServiceGitProperty(_serialization.Model): """Property of git environment. :ivar repositories: Repositories of Application Configuration Service git property. @@ -2664,25 +2481,20 @@ class ConfigurationServiceGitProperty(msrest.serialization.Model): """ _attribute_map = { - 'repositories': {'key': 'repositories', 'type': '[ConfigurationServiceGitRepository]'}, + "repositories": {"key": "repositories", "type": "[ConfigurationServiceGitRepository]"}, } - def __init__( - self, - *, - repositories: Optional[List["ConfigurationServiceGitRepository"]] = None, - **kwargs - ): + def __init__(self, *, repositories: Optional[List["_models.ConfigurationServiceGitRepository"]] = None, **kwargs): """ :keyword repositories: Repositories of Application Configuration Service git property. :paramtype repositories: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceGitRepository] """ - super(ConfigurationServiceGitProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.repositories = repositories -class ConfigurationServiceGitPropertyValidateResult(msrest.serialization.Model): +class ConfigurationServiceGitPropertyValidateResult(_serialization.Model): """Validation result for configuration service settings. :ivar is_valid: Indicate if the configuration service settings are valid. @@ -2693,15 +2505,15 @@ class ConfigurationServiceGitPropertyValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'git_repos_validation_result': {'key': 'gitReposValidationResult', 'type': '[ValidationMessages]'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "git_repos_validation_result": {"key": "gitReposValidationResult", "type": "[ValidationMessages]"}, } def __init__( self, *, is_valid: Optional[bool] = None, - git_repos_validation_result: Optional[List["ValidationMessages"]] = None, + git_repos_validation_result: Optional[List["_models.ValidationMessages"]] = None, **kwargs ): """ @@ -2711,23 +2523,23 @@ def __init__( :paramtype git_repos_validation_result: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.ValidationMessages] """ - super(ConfigurationServiceGitPropertyValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.git_repos_validation_result = git_repos_validation_result -class ConfigurationServiceGitRepository(msrest.serialization.Model): +class ConfigurationServiceGitRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes """Git repository property payload for Application Configuration Service. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the repository. + :ivar name: Name of the repository. Required. :vartype name: str - :ivar patterns: Required. Collection of patterns of the repository. + :ivar patterns: Collection of patterns of the repository. Required. :vartype patterns: list[str] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str - :ivar label: Required. Label of the repository. + :ivar label: Label of the repository. Required. :vartype label: str :ivar search_paths: Searching path of the repository. :vartype search_paths: list[str] @@ -2746,24 +2558,24 @@ class ConfigurationServiceGitRepository(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'patterns': {'required': True}, - 'uri': {'required': True}, - 'label': {'required': True}, + "name": {"required": True}, + "patterns": {"required": True}, + "uri": {"required": True}, + "label": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'patterns': {'key': 'patterns', 'type': '[str]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "patterns": {"key": "patterns", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( @@ -2783,13 +2595,13 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of the repository. + :keyword name: Name of the repository. Required. :paramtype name: str - :keyword patterns: Required. Collection of patterns of the repository. + :keyword patterns: Collection of patterns of the repository. Required. :paramtype patterns: list[str] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str - :keyword label: Required. Label of the repository. + :keyword label: Label of the repository. Required. :paramtype label: str :keyword search_paths: Searching path of the repository. :paramtype search_paths: list[str] @@ -2806,7 +2618,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(ConfigurationServiceGitRepository, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.patterns = patterns self.uri = uri @@ -2820,7 +2632,7 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ConfigurationServiceInstance(msrest.serialization.Model): +class ConfigurationServiceInstance(_serialization.Model): """Collection of instances belong to the Application Configuration Service. Variables are only populated by the server, and will be ignored when sending a request. @@ -2832,33 +2644,29 @@ class ConfigurationServiceInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ConfigurationServiceInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class ConfigurationServiceProperties(msrest.serialization.Model): +class ConfigurationServiceProperties(_serialization.Model): """Application Configuration Service properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Application Configuration Service. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Application Configuration Service. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceProvisioningState :ivar resource_requests: The requested resource quantity for required CPU and Memory. @@ -2873,30 +2681,25 @@ class ConfigurationServiceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'resource_requests': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'ConfigurationServiceResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[ConfigurationServiceInstance]'}, - 'settings': {'key': 'settings', 'type': 'ConfigurationServiceSettings'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "ConfigurationServiceResourceRequests"}, + "instances": {"key": "instances", "type": "[ConfigurationServiceInstance]"}, + "settings": {"key": "settings", "type": "ConfigurationServiceSettings"}, } - def __init__( - self, - *, - settings: Optional["ConfigurationServiceSettings"] = None, - **kwargs - ): + def __init__(self, *, settings: Optional["_models.ConfigurationServiceSettings"] = None, **kwargs): """ :keyword settings: The settings of Application Configuration Service. :paramtype settings: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceSettings """ - super(ConfigurationServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.resource_requests = None self.instances = None @@ -2922,36 +2725,31 @@ class ConfigurationServiceResource(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': 'ConfigurationServiceProperties'}, + "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": "ConfigurationServiceProperties"}, } - def __init__( - self, - *, - properties: Optional["ConfigurationServiceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ConfigurationServiceProperties"] = None, **kwargs): """ :keyword properties: Application Configuration Service properties payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceProperties """ - super(ConfigurationServiceResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ConfigurationServiceResourceCollection(msrest.serialization.Model): +class ConfigurationServiceResourceCollection(_serialization.Model): """Object that includes an array of configuration service resources and a possible link for next set. :ivar value: Collection of configuration service resources. @@ -2963,14 +2761,14 @@ class ConfigurationServiceResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ConfigurationServiceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ConfigurationServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ConfigurationServiceResource"]] = None, + value: Optional[List["_models.ConfigurationServiceResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2982,12 +2780,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ConfigurationServiceResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ConfigurationServiceResourceRequests(msrest.serialization.Model): +class ConfigurationServiceResourceRequests(_serialization.Model): """Resource request payload of Application Configuration Service. Variables are only populated by the server, and will be ignored when sending a request. @@ -3001,30 +2799,26 @@ class ConfigurationServiceResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, - 'instance_count': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ConfigurationServiceResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None self.instance_count = None -class ConfigurationServiceSettings(msrest.serialization.Model): +class ConfigurationServiceSettings(_serialization.Model): """The settings of Application Configuration Service. :ivar git_property: Property of git environment. @@ -3033,25 +2827,20 @@ class ConfigurationServiceSettings(msrest.serialization.Model): """ _attribute_map = { - 'git_property': {'key': 'gitProperty', 'type': 'ConfigurationServiceGitProperty'}, + "git_property": {"key": "gitProperty", "type": "ConfigurationServiceGitProperty"}, } - def __init__( - self, - *, - git_property: Optional["ConfigurationServiceGitProperty"] = None, - **kwargs - ): + def __init__(self, *, git_property: Optional["_models.ConfigurationServiceGitProperty"] = None, **kwargs): """ :keyword git_property: Property of git environment. :paramtype git_property: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceGitProperty """ - super(ConfigurationServiceSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property = git_property -class ConfigurationServiceSettingsValidateResult(msrest.serialization.Model): +class ConfigurationServiceSettingsValidateResult(_serialization.Model): """Validation result for configuration service settings. :ivar git_property_validation_result: Validation result for configuration service settings. @@ -3060,13 +2849,16 @@ class ConfigurationServiceSettingsValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'git_property_validation_result': {'key': 'gitPropertyValidationResult', 'type': 'ConfigurationServiceGitPropertyValidateResult'}, + "git_property_validation_result": { + "key": "gitPropertyValidationResult", + "type": "ConfigurationServiceGitPropertyValidateResult", + }, } def __init__( self, *, - git_property_validation_result: Optional["ConfigurationServiceGitPropertyValidateResult"] = None, + git_property_validation_result: Optional["_models.ConfigurationServiceGitPropertyValidateResult"] = None, **kwargs ): """ @@ -3074,11 +2866,11 @@ def __init__( :paramtype git_property_validation_result: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceGitPropertyValidateResult """ - super(ConfigurationServiceSettingsValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property_validation_result = git_property_validation_result -class ContainerProbeSettings(msrest.serialization.Model): +class ContainerProbeSettings(_serialization.Model): """Container liveness and readiness probe settings. :ivar disable_probe: Indicates whether disable the liveness and readiness probe. @@ -3086,20 +2878,15 @@ class ContainerProbeSettings(msrest.serialization.Model): """ _attribute_map = { - 'disable_probe': {'key': 'disableProbe', 'type': 'bool'}, + "disable_probe": {"key": "disableProbe", "type": "bool"}, } - def __init__( - self, - *, - disable_probe: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, disable_probe: Optional[bool] = None, **kwargs): """ :keyword disable_probe: Indicates whether disable the liveness and readiness probe. :paramtype disable_probe: bool """ - super(ContainerProbeSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.disable_probe = disable_probe @@ -3110,7 +2897,7 @@ class ContentCertificateProperties(CertificateProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -3131,44 +2918,39 @@ class ContentCertificateProperties(CertificateProperties): """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, - 'content': {'key': 'content', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "content": {"key": "content", "type": "str"}, } - def __init__( - self, - *, - content: Optional[str] = None, - **kwargs - ): + def __init__(self, *, content: Optional[str] = None, **kwargs): """ :keyword content: The content of uploaded certificate. :paramtype content: str """ - super(ContentCertificateProperties, self).__init__(**kwargs) - self.type = 'ContentCertificate' # type: str + super().__init__(**kwargs) + self.type = "ContentCertificate" # type: str self.content = content -class CustomContainer(msrest.serialization.Model): +class CustomContainer(_serialization.Model): """Custom container payload. :ivar server: The name of the registry that contains the container image. @@ -3190,12 +2972,12 @@ class CustomContainer(msrest.serialization.Model): """ _attribute_map = { - 'server': {'key': 'server', 'type': 'str'}, - 'container_image': {'key': 'containerImage', 'type': 'str'}, - 'command': {'key': 'command', 'type': '[str]'}, - 'args': {'key': 'args', 'type': '[str]'}, - 'image_registry_credential': {'key': 'imageRegistryCredential', 'type': 'ImageRegistryCredential'}, - 'language_framework': {'key': 'languageFramework', 'type': 'str'}, + "server": {"key": "server", "type": "str"}, + "container_image": {"key": "containerImage", "type": "str"}, + "command": {"key": "command", "type": "[str]"}, + "args": {"key": "args", "type": "[str]"}, + "image_registry_credential": {"key": "imageRegistryCredential", "type": "ImageRegistryCredential"}, + "language_framework": {"key": "languageFramework", "type": "str"}, } def __init__( @@ -3205,7 +2987,7 @@ def __init__( container_image: Optional[str] = None, command: Optional[List[str]] = None, args: Optional[List[str]] = None, - image_registry_credential: Optional["ImageRegistryCredential"] = None, + image_registry_credential: Optional["_models.ImageRegistryCredential"] = None, language_framework: Optional[str] = None, **kwargs ): @@ -3227,7 +3009,7 @@ def __init__( :keyword language_framework: Language framework of the container image uploaded. :paramtype language_framework: str """ - super(CustomContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.server = server self.container_image = container_image self.command = command @@ -3241,7 +3023,7 @@ class CustomContainerUserSourceInfo(UserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -3250,21 +3032,17 @@ class CustomContainerUserSourceInfo(UserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'custom_container': {'key': 'customContainer', 'type': 'CustomContainer'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "custom_container": {"key": "customContainer", "type": "CustomContainer"}, } def __init__( - self, - *, - version: Optional[str] = None, - custom_container: Optional["CustomContainer"] = None, - **kwargs + self, *, version: Optional[str] = None, custom_container: Optional["_models.CustomContainer"] = None, **kwargs ): """ :keyword version: Version of the source. @@ -3272,12 +3050,12 @@ def __init__( :keyword custom_container: Custom container payload. :paramtype custom_container: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomContainer """ - super(CustomContainerUserSourceInfo, self).__init__(version=version, **kwargs) - self.type = 'Container' # type: str + super().__init__(version=version, **kwargs) + self.type = "Container" # type: str self.custom_container = custom_container -class CustomDomainProperties(msrest.serialization.Model): +class CustomDomainProperties(_serialization.Model): """Custom domain of app resource payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -3291,29 +3069,23 @@ class CustomDomainProperties(msrest.serialization.Model): """ _validation = { - 'app_name': {'readonly': True}, + "app_name": {"readonly": True}, } _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'app_name': {'key': 'appName', 'type': 'str'}, - 'cert_name': {'key': 'certName', 'type': 'str'}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "app_name": {"key": "appName", "type": "str"}, + "cert_name": {"key": "certName", "type": "str"}, } - def __init__( - self, - *, - thumbprint: Optional[str] = None, - cert_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, thumbprint: Optional[str] = None, cert_name: Optional[str] = None, **kwargs): """ :keyword thumbprint: The thumbprint of bound certificate. :paramtype thumbprint: str :keyword cert_name: The bound certificate name of domain. :paramtype cert_name: str """ - super(CustomDomainProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = thumbprint self.app_name = None self.cert_name = cert_name @@ -3337,36 +3109,31 @@ class CustomDomainResource(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': 'CustomDomainProperties'}, + "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": "CustomDomainProperties"}, } - def __init__( - self, - *, - properties: Optional["CustomDomainProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CustomDomainProperties"] = None, **kwargs): """ :keyword properties: Properties of the custom domain resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainProperties """ - super(CustomDomainResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CustomDomainResourceCollection(msrest.serialization.Model): +class CustomDomainResourceCollection(_serialization.Model): """Collection compose of a custom domain resources list and a possible link for next page. :ivar value: The custom domain resources list. @@ -3376,16 +3143,12 @@ class CustomDomainResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CustomDomainResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CustomDomainResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The custom domain resources list. @@ -3393,43 +3156,38 @@ def __init__( :keyword next_link: The link to next page of custom domain list. :paramtype next_link: str """ - super(CustomDomainResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CustomDomainValidatePayload(msrest.serialization.Model): +class CustomDomainValidatePayload(_serialization.Model): """Custom domain validate payload. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name to be validated. + :ivar name: Name to be validated. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Name to be validated. + :keyword name: Name to be validated. Required. :paramtype name: str """ - super(CustomDomainValidatePayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CustomDomainValidateResult(msrest.serialization.Model): +class CustomDomainValidateResult(_serialization.Model): """Validation result for custom domain. :ivar is_valid: Indicates if domain name is valid. @@ -3439,29 +3197,23 @@ class CustomDomainValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'message': {'key': 'message', 'type': 'str'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - is_valid: Optional[bool] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, is_valid: Optional[bool] = None, message: Optional[str] = None, **kwargs): """ :keyword is_valid: Indicates if domain name is valid. :paramtype is_valid: bool :keyword message: Message of why domain name is invalid. :paramtype message: str """ - super(CustomDomainValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.message = message -class CustomPersistentDiskResource(msrest.serialization.Model): +class CustomPersistentDiskResource(_serialization.Model): """Custom persistent disk resource payload. All required parameters must be populated in order to send to Azure. @@ -3470,24 +3222,27 @@ class CustomPersistentDiskResource(msrest.serialization.Model): payload. :vartype custom_persistent_disk_properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomPersistentDiskProperties - :ivar storage_id: Required. The resource id of Azure Spring Cloud Storage resource. + :ivar storage_id: The resource id of Azure Spring Cloud Storage resource. Required. :vartype storage_id: str """ _validation = { - 'storage_id': {'required': True}, + "storage_id": {"required": True}, } _attribute_map = { - 'custom_persistent_disk_properties': {'key': 'customPersistentDiskProperties', 'type': 'CustomPersistentDiskProperties'}, - 'storage_id': {'key': 'storageId', 'type': 'str'}, + "custom_persistent_disk_properties": { + "key": "customPersistentDiskProperties", + "type": "CustomPersistentDiskProperties", + }, + "storage_id": {"key": "storageId", "type": "str"}, } def __init__( self, *, storage_id: str, - custom_persistent_disk_properties: Optional["CustomPersistentDiskProperties"] = None, + custom_persistent_disk_properties: Optional["_models.CustomPersistentDiskProperties"] = None, **kwargs ): """ @@ -3495,15 +3250,15 @@ def __init__( payload. :paramtype custom_persistent_disk_properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomPersistentDiskProperties - :keyword storage_id: Required. The resource id of Azure Spring Cloud Storage resource. + :keyword storage_id: The resource id of Azure Spring Cloud Storage resource. Required. :paramtype storage_id: str """ - super(CustomPersistentDiskResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.custom_persistent_disk_properties = custom_persistent_disk_properties self.storage_id = storage_id -class DeploymentInstance(msrest.serialization.Model): +class DeploymentInstance(_serialization.Model): """Deployment instance payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -3523,30 +3278,26 @@ class DeploymentInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, - 'reason': {'readonly': True}, - 'discovery_status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'zone': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, + "reason": {"readonly": True}, + "discovery_status": {"readonly": True}, + "start_time": {"readonly": True}, + "zone": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'discovery_status': {'key': 'discoveryStatus', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'zone': {'key': 'zone', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "discovery_status": {"key": "discoveryStatus", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, + "zone": {"key": "zone", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None self.reason = None @@ -3576,26 +3327,26 @@ class DeploymentResource(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': 'DeploymentResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "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": "DeploymentResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( self, *, - properties: Optional["DeploymentResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.DeploymentResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -3605,12 +3356,12 @@ def __init__( :keyword sku: Sku of the Deployment resource. :paramtype sku: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Sku """ - super(DeploymentResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.sku = sku -class DeploymentResourceCollection(msrest.serialization.Model): +class DeploymentResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of Deployment resources. @@ -3621,16 +3372,12 @@ class DeploymentResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["DeploymentResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.DeploymentResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Deployment resources. @@ -3639,12 +3386,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(DeploymentResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class DeploymentResourceProperties(msrest.serialization.Model): +class DeploymentResourceProperties(_serialization.Model): """Deployment resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -3654,11 +3401,11 @@ class DeploymentResourceProperties(msrest.serialization.Model): :ivar deployment_settings: Deployment settings of the Deployment. :vartype deployment_settings: ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentSettings - :ivar provisioning_state: Provisioning state of the Deployment. Possible values include: - "Creating", "Updating", "Succeeded", "Failed". + :ivar provisioning_state: Provisioning state of the Deployment. Known values are: "Creating", + "Updating", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResourceProvisioningState - :ivar status: Status of the Deployment. Possible values include: "Stopped", "Running". + :ivar status: Status of the Deployment. Known values are: "Stopped" and "Running". :vartype status: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResourceStatus :ivar active: Indicates whether the Deployment is active. @@ -3668,25 +3415,25 @@ class DeploymentResourceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'UserSourceInfo'}, - 'deployment_settings': {'key': 'deploymentSettings', 'type': 'DeploymentSettings'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'active': {'key': 'active', 'type': 'bool'}, - 'instances': {'key': 'instances', 'type': '[DeploymentInstance]'}, + "source": {"key": "source", "type": "UserSourceInfo"}, + "deployment_settings": {"key": "deploymentSettings", "type": "DeploymentSettings"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "active": {"key": "active", "type": "bool"}, + "instances": {"key": "instances", "type": "[DeploymentInstance]"}, } def __init__( self, *, - source: Optional["UserSourceInfo"] = None, - deployment_settings: Optional["DeploymentSettings"] = None, + source: Optional["_models.UserSourceInfo"] = None, + deployment_settings: Optional["_models.DeploymentSettings"] = None, active: Optional[bool] = None, **kwargs ): @@ -3699,7 +3446,7 @@ def __init__( :keyword active: Indicates whether the Deployment is active. :paramtype active: bool """ - super(DeploymentResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.deployment_settings = deployment_settings self.provisioning_state = None @@ -3708,7 +3455,7 @@ def __init__( self.instances = None -class DeploymentSettings(msrest.serialization.Model): +class DeploymentSettings(_serialization.Model): """Deployment settings payload. :ivar resource_requests: The requested resource quantity for required CPU and Memory. It is @@ -3718,26 +3465,26 @@ class DeploymentSettings(msrest.serialization.Model): :ivar environment_variables: Collection of environment variables. :vartype environment_variables: dict[str, str] :ivar addon_configs: Collection of addons. - :vartype addon_configs: dict[str, dict[str, any]] + :vartype addon_configs: dict[str, dict[str, JSON]] :ivar container_probe_settings: Container liveness and readiness probe settings. :vartype container_probe_settings: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ContainerProbeSettings """ _attribute_map = { - 'resource_requests': {'key': 'resourceRequests', 'type': 'ResourceRequests'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '{str}'}, - 'addon_configs': {'key': 'addonConfigs', 'type': '{{object}}'}, - 'container_probe_settings': {'key': 'containerProbeSettings', 'type': 'ContainerProbeSettings'}, + "resource_requests": {"key": "resourceRequests", "type": "ResourceRequests"}, + "environment_variables": {"key": "environmentVariables", "type": "{str}"}, + "addon_configs": {"key": "addonConfigs", "type": "{{object}}"}, + "container_probe_settings": {"key": "containerProbeSettings", "type": "ContainerProbeSettings"}, } def __init__( self, *, - resource_requests: Optional["ResourceRequests"] = None, + resource_requests: Optional["_models.ResourceRequests"] = None, environment_variables: Optional[Dict[str, str]] = None, - addon_configs: Optional[Dict[str, Dict[str, Any]]] = None, - container_probe_settings: Optional["ContainerProbeSettings"] = None, + addon_configs: Optional[Dict[str, Dict[str, JSON]]] = None, + container_probe_settings: Optional["_models.ContainerProbeSettings"] = None, **kwargs ): """ @@ -3749,19 +3496,19 @@ def __init__( :keyword environment_variables: Collection of environment variables. :paramtype environment_variables: dict[str, str] :keyword addon_configs: Collection of addons. - :paramtype addon_configs: dict[str, dict[str, any]] + :paramtype addon_configs: dict[str, dict[str, JSON]] :keyword container_probe_settings: Container liveness and readiness probe settings. :paramtype container_probe_settings: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ContainerProbeSettings """ - super(DeploymentSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_requests = resource_requests self.environment_variables = environment_variables self.addon_configs = addon_configs self.container_probe_settings = container_probe_settings -class DiagnosticParameters(msrest.serialization.Model): +class DiagnosticParameters(_serialization.Model): """Diagnostic parameters of diagnostic operations. :ivar app_instance: App instance name. @@ -3773,9 +3520,9 @@ class DiagnosticParameters(msrest.serialization.Model): """ _attribute_map = { - 'app_instance': {'key': 'appInstance', 'type': 'str'}, - 'file_path': {'key': 'filePath', 'type': 'str'}, - 'duration': {'key': 'duration', 'type': 'str'}, + "app_instance": {"key": "appInstance", "type": "str"}, + "file_path": {"key": "filePath", "type": "str"}, + "duration": {"key": "duration", "type": "str"}, } def __init__( @@ -3794,45 +3541,39 @@ def __init__( :keyword duration: Duration of your JFR. 1 min can be represented by 1m or 60s. :paramtype duration: str """ - super(DiagnosticParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.app_instance = app_instance self.file_path = file_path self.duration = duration -class Error(msrest.serialization.Model): +class Error(_serialization.Model): """The error code compose of code and message. :ivar code: The code of error. :vartype code: str :ivar message: The message of error. - :vartype message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + :vartype message: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: The code of error. :paramtype code: str :keyword message: The message of error. :paramtype message: str """ - super(Error, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class GatewayApiMetadataProperties(msrest.serialization.Model): +class GatewayApiMetadataProperties(_serialization.Model): """API metadata property for Spring Cloud Gateway. :ivar title: Title describing the context of the APIs available on the Gateway instance @@ -3851,11 +3592,11 @@ class GatewayApiMetadataProperties(msrest.serialization.Model): """ _attribute_map = { - 'title': {'key': 'title', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'documentation': {'key': 'documentation', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'server_url': {'key': 'serverUrl', 'type': 'str'}, + "title": {"key": "title", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "documentation": {"key": "documentation", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "server_url": {"key": "serverUrl", "type": "str"}, } def __init__( @@ -3885,7 +3626,7 @@ def __init__( instance. :paramtype server_url: str """ - super(GatewayApiMetadataProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.title = title self.description = description self.documentation = documentation @@ -3893,7 +3634,7 @@ def __init__( self.server_url = server_url -class GatewayApiRoute(msrest.serialization.Model): +class GatewayApiRoute(_serialization.Model): """API route config of the Spring Cloud Gateway. :ivar title: A title, will be applied to methods in the generated OpenAPI documentation. @@ -3917,21 +3658,21 @@ class GatewayApiRoute(msrest.serialization.Model): :vartype filters: list[str] :ivar order: Route processing order. :vartype order: int - :ivar tags: A set of tags. Classification tags, will be applied to methods in the generated - OpenAPI documentation. + :ivar tags: Classification tags, will be applied to methods in the generated OpenAPI + documentation. :vartype tags: list[str] """ _attribute_map = { - 'title': {'key': 'title', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'sso_enabled': {'key': 'ssoEnabled', 'type': 'bool'}, - 'token_relay': {'key': 'tokenRelay', 'type': 'bool'}, - 'predicates': {'key': 'predicates', 'type': '[str]'}, - 'filters': {'key': 'filters', 'type': '[str]'}, - 'order': {'key': 'order', 'type': 'int'}, - 'tags': {'key': 'tags', 'type': '[str]'}, + "title": {"key": "title", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "sso_enabled": {"key": "ssoEnabled", "type": "bool"}, + "token_relay": {"key": "tokenRelay", "type": "bool"}, + "predicates": {"key": "predicates", "type": "[str]"}, + "filters": {"key": "filters", "type": "[str]"}, + "order": {"key": "order", "type": "int"}, + "tags": {"key": "tags", "type": "[str]"}, } def __init__( @@ -3970,11 +3711,11 @@ def __init__( :paramtype filters: list[str] :keyword order: Route processing order. :paramtype order: int - :keyword tags: A set of tags. Classification tags, will be applied to methods in the generated - OpenAPI documentation. + :keyword tags: Classification tags, will be applied to methods in the generated OpenAPI + documentation. :paramtype tags: list[str] """ - super(GatewayApiRoute, self).__init__(**kwargs) + super().__init__(**kwargs) self.title = title self.description = description self.uri = uri @@ -3986,7 +3727,7 @@ def __init__( self.tags = tags -class GatewayCorsProperties(msrest.serialization.Model): +class GatewayCorsProperties(_serialization.Model): """Cross-Origin Resource Sharing property. :ivar allowed_origins: Allowed origins to make cross-site requests. The special value ``*`` @@ -4009,12 +3750,12 @@ class GatewayCorsProperties(msrest.serialization.Model): """ _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, - 'max_age': {'key': 'maxAge', 'type': 'int'}, - 'allow_credentials': {'key': 'allowCredentials', 'type': 'bool'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, + "max_age": {"key": "maxAge", "type": "int"}, + "allow_credentials": {"key": "allowCredentials", "type": "bool"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, } def __init__( @@ -4047,7 +3788,7 @@ def __init__( :keyword exposed_headers: HTTP response headers to expose for cross-site requests. :paramtype exposed_headers: list[str] """ - super(GatewayCorsProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.allowed_headers = allowed_headers @@ -4056,7 +3797,7 @@ def __init__( self.exposed_headers = exposed_headers -class GatewayCustomDomainProperties(msrest.serialization.Model): +class GatewayCustomDomainProperties(_serialization.Model): """The properties of custom domain for Spring Cloud Gateway. :ivar thumbprint: The thumbprint of bound certificate. @@ -4064,20 +3805,15 @@ class GatewayCustomDomainProperties(msrest.serialization.Model): """ _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, + "thumbprint": {"key": "thumbprint", "type": "str"}, } - def __init__( - self, - *, - thumbprint: Optional[str] = None, - **kwargs - ): + def __init__(self, *, thumbprint: Optional[str] = None, **kwargs): """ :keyword thumbprint: The thumbprint of bound certificate. :paramtype thumbprint: str """ - super(GatewayCustomDomainProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = thumbprint @@ -4100,36 +3836,31 @@ class GatewayCustomDomainResource(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': 'GatewayCustomDomainProperties'}, + "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": "GatewayCustomDomainProperties"}, } - def __init__( - self, - *, - properties: Optional["GatewayCustomDomainProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.GatewayCustomDomainProperties"] = None, **kwargs): """ :keyword properties: The properties of custom domain for Spring Cloud Gateway. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainProperties """ - super(GatewayCustomDomainResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class GatewayCustomDomainResourceCollection(msrest.serialization.Model): +class GatewayCustomDomainResourceCollection(_serialization.Model): """Object that includes an array of Spring Cloud Gateway custom domain resources and a possible link for next set. :ivar value: Collection of Spring Cloud Gateway custom domain resources. @@ -4141,14 +3872,14 @@ class GatewayCustomDomainResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayCustomDomainResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GatewayCustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["GatewayCustomDomainResource"]] = None, + value: Optional[List["_models.GatewayCustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -4160,12 +3891,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(GatewayCustomDomainResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class GatewayInstance(msrest.serialization.Model): +class GatewayInstance(_serialization.Model): """Collection of instances belong to the Spring Cloud Gateway. Variables are only populated by the server, and will be ignored when sending a request. @@ -4177,27 +3908,23 @@ class GatewayInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GatewayInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class GatewayOperatorProperties(msrest.serialization.Model): +class GatewayOperatorProperties(_serialization.Model): """Properties of the Spring Cloud Gateway Operator. Variables are only populated by the server, and will be ignored when sending a request. @@ -4210,27 +3937,23 @@ class GatewayOperatorProperties(msrest.serialization.Model): """ _validation = { - 'resource_requests': {'readonly': True}, - 'instances': {'readonly': True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'resource_requests': {'key': 'resourceRequests', 'type': 'GatewayOperatorResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[GatewayInstance]'}, + "resource_requests": {"key": "resourceRequests", "type": "GatewayOperatorResourceRequests"}, + "instances": {"key": "instances", "type": "[GatewayInstance]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GatewayOperatorProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_requests = None self.instances = None -class GatewayOperatorResourceRequests(msrest.serialization.Model): +class GatewayOperatorResourceRequests(_serialization.Model): """Properties of the Spring Cloud Gateway Operator. Variables are only populated by the server, and will be ignored when sending a request. @@ -4244,36 +3967,32 @@ class GatewayOperatorResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, - 'instance_count': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GatewayOperatorResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None self.instance_count = None -class GatewayProperties(msrest.serialization.Model): +class GatewayProperties(_serialization.Model): """Spring Cloud Gateway properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Spring Cloud Gateway. Possible values include: - "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Spring Cloud Gateway. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayProvisioningState :ivar public: Indicates whether the Spring Cloud Gateway exposes endpoint. @@ -4301,34 +4020,34 @@ class GatewayProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'url': {'readonly': True}, - 'instances': {'readonly': True}, - 'operator_properties': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "url": {"readonly": True}, + "instances": {"readonly": True}, + "operator_properties": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'public': {'key': 'public', 'type': 'bool'}, - 'url': {'key': 'url', 'type': 'str'}, - 'https_only': {'key': 'httpsOnly', 'type': 'bool'}, - 'sso_properties': {'key': 'ssoProperties', 'type': 'SsoProperties'}, - 'api_metadata_properties': {'key': 'apiMetadataProperties', 'type': 'GatewayApiMetadataProperties'}, - 'cors_properties': {'key': 'corsProperties', 'type': 'GatewayCorsProperties'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'GatewayResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[GatewayInstance]'}, - 'operator_properties': {'key': 'operatorProperties', 'type': 'GatewayOperatorProperties'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "sso_properties": {"key": "ssoProperties", "type": "SsoProperties"}, + "api_metadata_properties": {"key": "apiMetadataProperties", "type": "GatewayApiMetadataProperties"}, + "cors_properties": {"key": "corsProperties", "type": "GatewayCorsProperties"}, + "resource_requests": {"key": "resourceRequests", "type": "GatewayResourceRequests"}, + "instances": {"key": "instances", "type": "[GatewayInstance]"}, + "operator_properties": {"key": "operatorProperties", "type": "GatewayOperatorProperties"}, } def __init__( self, *, - public: Optional[bool] = False, - https_only: Optional[bool] = False, - sso_properties: Optional["SsoProperties"] = None, - api_metadata_properties: Optional["GatewayApiMetadataProperties"] = None, - cors_properties: Optional["GatewayCorsProperties"] = None, - resource_requests: Optional["GatewayResourceRequests"] = None, + public: bool = False, + https_only: bool = False, + sso_properties: Optional["_models.SsoProperties"] = None, + api_metadata_properties: Optional["_models.GatewayApiMetadataProperties"] = None, + cors_properties: Optional["_models.GatewayCorsProperties"] = None, + resource_requests: Optional["_models.GatewayResourceRequests"] = None, **kwargs ): """ @@ -4348,7 +4067,7 @@ def __init__( :paramtype resource_requests: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResourceRequests """ - super(GatewayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.public = public self.url = None @@ -4381,27 +4100,23 @@ class GatewayResource(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': 'GatewayProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "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": "GatewayProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( - self, - *, - properties: Optional["GatewayProperties"] = None, - sku: Optional["Sku"] = None, - **kwargs + self, *, properties: Optional["_models.GatewayProperties"] = None, sku: Optional["_models.Sku"] = None, **kwargs ): """ :keyword properties: Spring Cloud Gateway properties payload. @@ -4409,12 +4124,12 @@ def __init__( :keyword sku: Sku of the Spring Cloud Gateway resource. :paramtype sku: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Sku """ - super(GatewayResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.sku = sku -class GatewayResourceCollection(msrest.serialization.Model): +class GatewayResourceCollection(_serialization.Model): """Object that includes an array of gateway resources and a possible link for next set. :ivar value: Collection of gateway resources. @@ -4425,16 +4140,12 @@ class GatewayResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GatewayResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["GatewayResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.GatewayResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of gateway resources. @@ -4443,12 +4154,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(GatewayResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class GatewayResourceRequests(msrest.serialization.Model): +class GatewayResourceRequests(_serialization.Model): """Resource request payload of Spring Cloud Gateway. :ivar cpu: Cpu allocated to each Spring Cloud Gateway instance. @@ -4458,35 +4169,29 @@ class GatewayResourceRequests(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - *, - cpu: Optional[str] = None, - memory: Optional[str] = None, - **kwargs - ): + def __init__(self, *, cpu: str = "1", memory: str = "2Gi", **kwargs): """ :keyword cpu: Cpu allocated to each Spring Cloud Gateway instance. :paramtype cpu: str :keyword memory: Memory allocated to each Spring Cloud Gateway instance. :paramtype memory: str """ - super(GatewayResourceRequests, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory = memory -class GatewayRouteConfigProperties(msrest.serialization.Model): +class GatewayRouteConfigProperties(_serialization.Model): """API route config of the Spring Cloud Gateway. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Spring Cloud Gateway route config. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Spring Cloud Gateway route config. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayProvisioningState :ivar app_resource_id: The resource Id of the Azure Spring Cloud app, required unless route @@ -4498,20 +4203,20 @@ class GatewayRouteConfigProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'app_resource_id': {'key': 'appResourceId', 'type': 'str'}, - 'routes': {'key': 'routes', 'type': '[GatewayApiRoute]'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "app_resource_id": {"key": "appResourceId", "type": "str"}, + "routes": {"key": "routes", "type": "[GatewayApiRoute]"}, } def __init__( self, *, app_resource_id: Optional[str] = None, - routes: Optional[List["GatewayApiRoute"]] = None, + routes: Optional[List["_models.GatewayApiRoute"]] = None, **kwargs ): """ @@ -4522,7 +4227,7 @@ def __init__( ``uri``\ , ``ssoEnabled``\ , ``predicates``\ , ``filters``. :paramtype routes: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayApiRoute] """ - super(GatewayRouteConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.app_resource_id = app_resource_id self.routes = routes @@ -4547,36 +4252,31 @@ class GatewayRouteConfigResource(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': 'GatewayRouteConfigProperties'}, + "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": "GatewayRouteConfigProperties"}, } - def __init__( - self, - *, - properties: Optional["GatewayRouteConfigProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.GatewayRouteConfigProperties"] = None, **kwargs): """ :keyword properties: API route config of the Spring Cloud Gateway. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigProperties """ - super(GatewayRouteConfigResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class GatewayRouteConfigResourceCollection(msrest.serialization.Model): +class GatewayRouteConfigResourceCollection(_serialization.Model): """Object that includes an array of Spring Cloud Gateway route config resources and a possible link for next set. :ivar value: Collection of Spring Cloud Gateway route config resources. @@ -4588,14 +4288,14 @@ class GatewayRouteConfigResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayRouteConfigResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GatewayRouteConfigResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["GatewayRouteConfigResource"]] = None, + value: Optional[List["_models.GatewayRouteConfigResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -4607,21 +4307,21 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(GatewayRouteConfigResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class GitPatternRepository(msrest.serialization.Model): +class GitPatternRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes """Git repository property payload for config server. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the repository. + :ivar name: Name of the repository. Required. :vartype name: str :ivar pattern: Collection of pattern of the repository. :vartype pattern: list[str] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -4642,22 +4342,22 @@ class GitPatternRepository(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'uri': {'required': True}, + "name": {"required": True}, + "uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'pattern': {'key': 'pattern', 'type': '[str]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "pattern": {"key": "pattern", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( @@ -4677,11 +4377,11 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of the repository. + :keyword name: Name of the repository. Required. :paramtype name: str :keyword pattern: Collection of pattern of the repository. :paramtype pattern: list[str] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -4700,7 +4400,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(GitPatternRepository, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.pattern = pattern self.uri = uri @@ -4714,7 +4414,7 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ImageRegistryCredential(msrest.serialization.Model): +class ImageRegistryCredential(_serialization.Model): """Credential of the image registry. :ivar username: The username of the image registry credential. @@ -4724,24 +4424,18 @@ class ImageRegistryCredential(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - username: Optional[str] = None, - password: Optional[str] = None, - **kwargs - ): + def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs): """ :keyword username: The username of the image registry credential. :paramtype username: str :keyword password: The password of the image registry credential. :paramtype password: str """ - super(ImageRegistryCredential, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.password = password @@ -4749,12 +4443,12 @@ def __init__( class UploadedUserSourceInfo(UserSourceInfo): """Source with uploaded location. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: JarUploadedUserSourceInfo, NetCoreZipUploadedUserSourceInfo, SourceUploadedUserSourceInfo. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + JarUploadedUserSourceInfo, NetCoreZipUploadedUserSourceInfo, SourceUploadedUserSourceInfo All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -4763,34 +4457,32 @@ class UploadedUserSourceInfo(UserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, } _subtype_map = { - 'type': {'Jar': 'JarUploadedUserSourceInfo', 'NetCoreZip': 'NetCoreZipUploadedUserSourceInfo', 'Source': 'SourceUploadedUserSourceInfo'} + "type": { + "Jar": "JarUploadedUserSourceInfo", + "NetCoreZip": "NetCoreZipUploadedUserSourceInfo", + "Source": "SourceUploadedUserSourceInfo", + } } - def __init__( - self, - *, - version: Optional[str] = None, - relative_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, version: Optional[str] = None, relative_path: Optional[str] = None, **kwargs): """ :keyword version: Version of the source. :paramtype version: str :keyword relative_path: Relative path of the storage which stores the source. :paramtype relative_path: str """ - super(UploadedUserSourceInfo, self).__init__(version=version, **kwargs) - self.type = 'UploadedUserSourceInfo' # type: str + super().__init__(version=version, **kwargs) + self.type = "UploadedUserSourceInfo" # type: str self.relative_path = relative_path @@ -4799,7 +4491,7 @@ class JarUploadedUserSourceInfo(UploadedUserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -4812,15 +4504,15 @@ class JarUploadedUserSourceInfo(UploadedUserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, - 'jvm_options': {'key': 'jvmOptions', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, + "jvm_options": {"key": "jvmOptions", "type": "str"}, } def __init__( @@ -4842,20 +4534,20 @@ def __init__( :keyword jvm_options: JVM parameter. :paramtype jvm_options: str """ - super(JarUploadedUserSourceInfo, self).__init__(version=version, relative_path=relative_path, **kwargs) - self.type = 'Jar' # type: str + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "Jar" # type: str self.runtime_version = runtime_version self.jvm_options = jvm_options -class KeyVaultCertificateProperties(CertificateProperties): +class KeyVaultCertificateProperties(CertificateProperties): # pylint: disable=too-many-instance-attributes """Properties of certificate imported from key vault. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -4871,9 +4563,9 @@ class KeyVaultCertificateProperties(CertificateProperties): :vartype subject_name: str :ivar dns_names: The domain list of certificate. :vartype dns_names: list[str] - :ivar vault_uri: Required. The vault uri of user key vault. + :ivar vault_uri: The vault uri of user key vault. Required. :vartype vault_uri: str - :ivar key_vault_cert_name: Required. The certificate name of key vault. + :ivar key_vault_cert_name: The certificate name of key vault. Required. :vartype key_vault_cert_name: str :ivar cert_version: The certificate version of key vault. :vartype cert_version: str @@ -4883,31 +4575,31 @@ class KeyVaultCertificateProperties(CertificateProperties): """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, - 'vault_uri': {'required': True}, - 'key_vault_cert_name': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, - 'vault_uri': {'key': 'vaultUri', 'type': 'str'}, - 'key_vault_cert_name': {'key': 'keyVaultCertName', 'type': 'str'}, - 'cert_version': {'key': 'certVersion', 'type': 'str'}, - 'exclude_private_key': {'key': 'excludePrivateKey', 'type': 'bool'}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, + "vault_uri": {"required": True}, + "key_vault_cert_name": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "vault_uri": {"key": "vaultUri", "type": "str"}, + "key_vault_cert_name": {"key": "keyVaultCertName", "type": "str"}, + "cert_version": {"key": "certVersion", "type": "str"}, + "exclude_private_key": {"key": "excludePrivateKey", "type": "bool"}, } def __init__( @@ -4916,13 +4608,13 @@ def __init__( vault_uri: str, key_vault_cert_name: str, cert_version: Optional[str] = None, - exclude_private_key: Optional[bool] = False, + exclude_private_key: bool = False, **kwargs ): """ - :keyword vault_uri: Required. The vault uri of user key vault. + :keyword vault_uri: The vault uri of user key vault. Required. :paramtype vault_uri: str - :keyword key_vault_cert_name: Required. The certificate name of key vault. + :keyword key_vault_cert_name: The certificate name of key vault. Required. :paramtype key_vault_cert_name: str :keyword cert_version: The certificate version of key vault. :paramtype cert_version: str @@ -4930,20 +4622,20 @@ def __init__( vault. :paramtype exclude_private_key: bool """ - super(KeyVaultCertificateProperties, self).__init__(**kwargs) - self.type = 'KeyVaultCertificate' # type: str + super().__init__(**kwargs) + self.type = "KeyVaultCertificate" # type: str self.vault_uri = vault_uri self.key_vault_cert_name = key_vault_cert_name self.cert_version = cert_version self.exclude_private_key = exclude_private_key -class LoadedCertificate(msrest.serialization.Model): +class LoadedCertificate(_serialization.Model): """Loaded certificate payload. All required parameters must be populated in order to send to Azure. - :ivar resource_id: Required. Resource Id of loaded certificate. + :ivar resource_id: Resource Id of loaded certificate. Required. :vartype resource_id: str :ivar load_trust_store: Indicate whether the certificate will be loaded into default trust store, only work for Java runtime. @@ -4951,65 +4643,54 @@ class LoadedCertificate(msrest.serialization.Model): """ _validation = { - 'resource_id': {'required': True}, + "resource_id": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'load_trust_store': {'key': 'loadTrustStore', 'type': 'bool'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "load_trust_store": {"key": "loadTrustStore", "type": "bool"}, } - def __init__( - self, - *, - resource_id: str, - load_trust_store: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, resource_id: str, load_trust_store: bool = False, **kwargs): """ - :keyword resource_id: Required. Resource Id of loaded certificate. + :keyword resource_id: Resource Id of loaded certificate. Required. :paramtype resource_id: str :keyword load_trust_store: Indicate whether the certificate will be loaded into default trust store, only work for Java runtime. :paramtype load_trust_store: bool """ - super(LoadedCertificate, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.load_trust_store = load_trust_store -class LogFileUrlResponse(msrest.serialization.Model): +class LogFileUrlResponse(_serialization.Model): """Log file URL payload. All required parameters must be populated in order to send to Azure. - :ivar url: Required. URL of the log file. + :ivar url: URL of the log file. Required. :vartype url: str """ _validation = { - 'url': {'required': True}, + "url": {"required": True}, } _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, } - def __init__( - self, - *, - url: str, - **kwargs - ): + def __init__(self, *, url: str, **kwargs): """ - :keyword url: Required. URL of the log file. + :keyword url: URL of the log file. Required. :paramtype url: str """ - super(LogFileUrlResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url -class LogSpecification(msrest.serialization.Model): +class LogSpecification(_serialization.Model): """Specifications of the Log for Azure Monitoring. :ivar name: Name of the log. @@ -5021,9 +4702,9 @@ class LogSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, } def __init__( @@ -5042,17 +4723,17 @@ def __init__( :keyword blob_duration: Blob duration of the log. :paramtype blob_duration: str """ - super(LogSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class ManagedIdentityProperties(msrest.serialization.Model): +class ManagedIdentityProperties(_serialization.Model): """Managed identity properties retrieved from ARM request headers. - :ivar type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.ManagedIdentityType :ivar principal_id: Principal Id of system-assigned managed identity. :vartype principal_id: str @@ -5064,24 +4745,24 @@ class ManagedIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedManagedIdentity}'}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedManagedIdentity}"}, } def __init__( self, *, - type: Optional[Union[str, "ManagedIdentityType"]] = None, + type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedManagedIdentity"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedManagedIdentity"]] = None, **kwargs ): """ - :keyword type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.ManagedIdentityType :keyword principal_id: Principal Id of system-assigned managed identity. :paramtype principal_id: str @@ -5091,14 +4772,14 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.appplatform.v2022_03_01_preview.models.UserAssignedManagedIdentity] """ - super(ManagedIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.principal_id = principal_id self.tenant_id = tenant_id self.user_assigned_identities = user_assigned_identities -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """Specifications of the Dimension of metrics. :ivar name: Name of the dimension. @@ -5111,9 +4792,9 @@ class MetricDimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -5133,13 +4814,13 @@ def __init__( export scenario. :paramtype to_be_exported_for_shoebox: bool """ - super(MetricDimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes """Specifications of the Metrics for Azure Monitoring. :ivar name: Name of the metric. @@ -5170,17 +4851,17 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "source_mdm_namespace": {"key": "sourceMdmNamespace", "type": "str"}, } def __init__( @@ -5195,7 +4876,7 @@ def __init__( supported_aggregation_types: Optional[List[str]] = None, supported_time_grain_types: Optional[List[str]] = None, fill_gap_with_zero: Optional[bool] = None, - dimensions: Optional[List["MetricDimension"]] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, source_mdm_namespace: Optional[str] = None, **kwargs ): @@ -5226,7 +4907,7 @@ def __init__( :keyword source_mdm_namespace: Name of the MDM namespace. Optional. :paramtype source_mdm_namespace: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -5240,13 +4921,13 @@ def __init__( self.source_mdm_namespace = source_mdm_namespace -class MonitoringSettingProperties(msrest.serialization.Model): +class MonitoringSettingProperties(_serialization.Model): """Monitoring Setting properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Monitoring Setting. Possible values include: - "NotAvailable", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the Monitoring Setting. Known values are: "NotAvailable", + "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingState :ivar error: Error when apply Monitoring Setting changes. @@ -5267,27 +4948,27 @@ class MonitoringSettingProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'app_insights_sampling_rate': {'maximum': 100, 'minimum': 0}, + "provisioning_state": {"readonly": True}, + "app_insights_sampling_rate": {"maximum": 100, "minimum": 0}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'trace_enabled': {'key': 'traceEnabled', 'type': 'bool'}, - 'app_insights_instrumentation_key': {'key': 'appInsightsInstrumentationKey', 'type': 'str'}, - 'app_insights_sampling_rate': {'key': 'appInsightsSamplingRate', 'type': 'float'}, - 'app_insights_agent_versions': {'key': 'appInsightsAgentVersions', 'type': 'ApplicationInsightsAgentVersions'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "trace_enabled": {"key": "traceEnabled", "type": "bool"}, + "app_insights_instrumentation_key": {"key": "appInsightsInstrumentationKey", "type": "str"}, + "app_insights_sampling_rate": {"key": "appInsightsSamplingRate", "type": "float"}, + "app_insights_agent_versions": {"key": "appInsightsAgentVersions", "type": "ApplicationInsightsAgentVersions"}, } def __init__( self, *, - error: Optional["Error"] = None, + error: Optional["_models.Error"] = None, trace_enabled: Optional[bool] = None, app_insights_instrumentation_key: Optional[str] = None, app_insights_sampling_rate: Optional[float] = None, - app_insights_agent_versions: Optional["ApplicationInsightsAgentVersions"] = None, + app_insights_agent_versions: Optional["_models.ApplicationInsightsAgentVersions"] = None, **kwargs ): """ @@ -5307,7 +4988,7 @@ def __init__( :paramtype app_insights_agent_versions: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApplicationInsightsAgentVersions """ - super(MonitoringSettingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.trace_enabled = trace_enabled @@ -5335,36 +5016,31 @@ class MonitoringSettingResource(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': 'MonitoringSettingProperties'}, + "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": "MonitoringSettingProperties"}, } - def __init__( - self, - *, - properties: Optional["MonitoringSettingProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.MonitoringSettingProperties"] = None, **kwargs): """ :keyword properties: Properties of the Monitoring Setting resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingProperties """ - super(MonitoringSettingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class NameAvailability(msrest.serialization.Model): +class NameAvailability(_serialization.Model): """Name availability result payload. :ivar name_available: Indicates whether the name is available. @@ -5376,9 +5052,9 @@ class NameAvailability(msrest.serialization.Model): """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } def __init__( @@ -5397,47 +5073,41 @@ def __init__( :keyword message: Message why the name is not available. :paramtype message: str """ - super(NameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class NameAvailabilityParameters(msrest.serialization.Model): +class NameAvailabilityParameters(_serialization.Model): """Name availability parameters payload. All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the resource to check name availability. + :ivar type: Type of the resource to check name availability. Required. :vartype type: str - :ivar name: Required. Name to be checked. + :ivar name: Name to be checked. Required. :vartype name: str """ _validation = { - 'type': {'required': True}, - 'name': {'required': True}, + "type": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - type: str, - name: str, - **kwargs - ): + def __init__(self, *, type: str, name: str, **kwargs): """ - :keyword type: Required. Type of the resource to check name availability. + :keyword type: Type of the resource to check name availability. Required. :paramtype type: str - :keyword name: Required. Name to be checked. + :keyword name: Name to be checked. Required. :paramtype name: str """ - super(NameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name @@ -5447,7 +5117,7 @@ class NetCoreZipUploadedUserSourceInfo(UploadedUserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -5460,15 +5130,15 @@ class NetCoreZipUploadedUserSourceInfo(UploadedUserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'net_core_main_entry_path': {'key': 'netCoreMainEntryPath', 'type': 'str'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "net_core_main_entry_path": {"key": "netCoreMainEntryPath", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, } def __init__( @@ -5490,13 +5160,13 @@ def __init__( :keyword runtime_version: Runtime version of the .Net file. :paramtype runtime_version: str """ - super(NetCoreZipUploadedUserSourceInfo, self).__init__(version=version, relative_path=relative_path, **kwargs) - self.type = 'NetCoreZip' # type: str + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "NetCoreZip" # type: str self.net_core_main_entry_path = net_core_main_entry_path self.runtime_version = runtime_version -class NetworkProfile(msrest.serialization.Model): +class NetworkProfile(_serialization.Model): """Service network profile payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -5523,18 +5193,18 @@ class NetworkProfile(msrest.serialization.Model): """ _validation = { - 'outbound_i_ps': {'readonly': True}, - 'required_traffics': {'readonly': True}, + "outbound_i_ps": {"readonly": True}, + "required_traffics": {"readonly": True}, } _attribute_map = { - 'service_runtime_subnet_id': {'key': 'serviceRuntimeSubnetId', 'type': 'str'}, - 'app_subnet_id': {'key': 'appSubnetId', 'type': 'str'}, - 'service_cidr': {'key': 'serviceCidr', 'type': 'str'}, - 'service_runtime_network_resource_group': {'key': 'serviceRuntimeNetworkResourceGroup', 'type': 'str'}, - 'app_network_resource_group': {'key': 'appNetworkResourceGroup', 'type': 'str'}, - 'outbound_i_ps': {'key': 'outboundIPs', 'type': 'NetworkProfileOutboundIPs'}, - 'required_traffics': {'key': 'requiredTraffics', 'type': '[RequiredTraffic]'}, + "service_runtime_subnet_id": {"key": "serviceRuntimeSubnetId", "type": "str"}, + "app_subnet_id": {"key": "appSubnetId", "type": "str"}, + "service_cidr": {"key": "serviceCidr", "type": "str"}, + "service_runtime_network_resource_group": {"key": "serviceRuntimeNetworkResourceGroup", "type": "str"}, + "app_network_resource_group": {"key": "appNetworkResourceGroup", "type": "str"}, + "outbound_i_ps": {"key": "outboundIPs", "type": "NetworkProfileOutboundIPs"}, + "required_traffics": {"key": "requiredTraffics", "type": "[RequiredTraffic]"}, } def __init__( @@ -5563,7 +5233,7 @@ def __init__( Azure Spring Cloud Apps. :paramtype app_network_resource_group: str """ - super(NetworkProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_runtime_subnet_id = service_runtime_subnet_id self.app_subnet_id = app_subnet_id self.service_cidr = service_cidr @@ -5573,7 +5243,7 @@ def __init__( self.required_traffics = None -class NetworkProfileOutboundIPs(msrest.serialization.Model): +class NetworkProfileOutboundIPs(_serialization.Model): """Desired outbound IP resources for Azure Spring Cloud instance. Variables are only populated by the server, and will be ignored when sending a request. @@ -5583,24 +5253,20 @@ class NetworkProfileOutboundIPs(msrest.serialization.Model): """ _validation = { - 'public_i_ps': {'readonly': True}, + "public_i_ps": {"readonly": True}, } _attribute_map = { - 'public_i_ps': {'key': 'publicIPs', 'type': '[str]'}, + "public_i_ps": {"key": "publicIPs", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(NetworkProfileOutboundIPs, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.public_i_ps = None -class OperationDetail(msrest.serialization.Model): +class OperationDetail(_serialization.Model): """Operation detail payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -5612,7 +5278,7 @@ class OperationDetail(msrest.serialization.Model): :ivar display: Display of the operation. :vartype display: ~azure.mgmt.appplatform.v2022_03_01_preview.models.OperationDisplay :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. Possible values include: "Internal". + internal only APIs. "Internal" :vartype action_type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.ActionType :ivar origin: Origin of the operation. :vartype origin: str @@ -5621,16 +5287,16 @@ class OperationDetail(msrest.serialization.Model): """ _validation = { - 'action_type': {'readonly': True}, + "action_type": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'action_type': {'key': 'actionType', 'type': 'str'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "action_type": {"key": "actionType", "type": "str"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "OperationProperties"}, } def __init__( @@ -5638,9 +5304,9 @@ 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, - properties: Optional["OperationProperties"] = None, + properties: Optional["_models.OperationProperties"] = None, **kwargs ): """ @@ -5655,7 +5321,7 @@ def __init__( :keyword properties: Properties of the operation. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.OperationProperties """ - super(OperationDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display @@ -5664,7 +5330,7 @@ def __init__( self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display payload. :ivar provider: Resource provider of the operation. @@ -5678,10 +5344,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__( @@ -5703,14 +5369,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 OperationProperties(msrest.serialization.Model): +class OperationProperties(_serialization.Model): """Extra Operation properties. :ivar service_specification: Service specifications of the operation. @@ -5719,25 +5385,20 @@ class OperationProperties(msrest.serialization.Model): """ _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, } - def __init__( - self, - *, - service_specification: Optional["ServiceSpecification"] = None, - **kwargs - ): + def __init__(self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs): """ :keyword service_specification: Service specifications of the operation. :paramtype service_specification: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceSpecification """ - super(OperationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_specification = service_specification -class PersistentDisk(msrest.serialization.Model): +class PersistentDisk(_serialization.Model): """Persistent disk payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -5751,69 +5412,56 @@ class PersistentDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 50, 'minimum': 0}, - 'used_in_gb': {'readonly': True, 'maximum': 50, 'minimum': 0}, + "size_in_gb": {"maximum": 50, "minimum": 0}, + "used_in_gb": {"readonly": True, "maximum": 50, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'used_in_gb': {'key': 'usedInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "used_in_gb": {"key": "usedInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: Optional[str] = None, **kwargs): """ :keyword size_in_gb: Size of the persistent disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the persistent disk. :paramtype mount_path: str """ - super(PersistentDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.used_in_gb = None self.mount_path = mount_path -class RegenerateTestKeyRequestPayload(msrest.serialization.Model): +class RegenerateTestKeyRequestPayload(_serialization.Model): """Regenerate test key request payload. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :ivar key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :vartype key_type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.TestKeyType """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "TestKeyType"], - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.TestKeyType"], **kwargs): """ - :keyword key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :keyword key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :paramtype key_type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.TestKeyType """ - super(RegenerateTestKeyRequestPayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type -class RequiredTraffic(msrest.serialization.Model): +class RequiredTraffic(_serialization.Model): """Required inbound or outbound traffic for Azure Spring Cloud instance. Variables are only populated by the server, and will be ignored when sending a request. @@ -5826,34 +5474,29 @@ class RequiredTraffic(msrest.serialization.Model): :vartype ips: list[str] :ivar fqdns: The FQDN list of required traffic. :vartype fqdns: list[str] - :ivar direction: The direction of required traffic. Possible values include: "Inbound", - "Outbound". + :ivar direction: The direction of required traffic. Known values are: "Inbound" and "Outbound". :vartype direction: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.TrafficDirection """ _validation = { - 'protocol': {'readonly': True}, - 'port': {'readonly': True}, - 'ips': {'readonly': True}, - 'fqdns': {'readonly': True}, - 'direction': {'readonly': True}, + "protocol": {"readonly": True}, + "port": {"readonly": True}, + "ips": {"readonly": True}, + "fqdns": {"readonly": True}, + "direction": {"readonly": True}, } _attribute_map = { - 'protocol': {'key': 'protocol', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - 'ips': {'key': 'ips', 'type': '[str]'}, - 'fqdns': {'key': 'fqdns', 'type': '[str]'}, - 'direction': {'key': 'direction', 'type': 'str'}, + "protocol": {"key": "protocol", "type": "str"}, + "port": {"key": "port", "type": "int"}, + "ips": {"key": "ips", "type": "[str]"}, + "fqdns": {"key": "fqdns", "type": "[str]"}, + "direction": {"key": "direction", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RequiredTraffic, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.protocol = None self.port = None self.ips = None @@ -5861,7 +5504,7 @@ def __init__( self.direction = None -class ResourceRequests(msrest.serialization.Model): +class ResourceRequests(_serialization.Model): """Deployment resource request payload. :ivar cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 for @@ -5873,17 +5516,11 @@ class ResourceRequests(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - *, - cpu: Optional[str] = None, - memory: Optional[str] = None, - **kwargs - ): + def __init__(self, *, cpu: Optional[str] = None, memory: Optional[str] = None, **kwargs): """ :keyword cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 for Basic tier, and {500m, 1, 2, 3, 4} for Standard tier. @@ -5892,12 +5529,12 @@ def __init__( {512Mi, 1Gi, 2Gi} for Basic tier, and {512Mi, 1Gi, 2Gi, ..., 8Gi} for Standard tier. :paramtype memory: str """ - super(ResourceRequests, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory = memory -class ResourceSku(msrest.serialization.Model): +class ResourceSku(_serialization.Model): """Describes an available Azure Spring Cloud SKU. :ivar resource_type: Gets the type of resource the SKU applies to. @@ -5921,13 +5558,13 @@ class ResourceSku(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'SkuCapacity'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[ResourceSkuLocationInfo]'}, - 'restrictions': {'key': 'restrictions', 'type': '[ResourceSkuRestrictions]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "SkuCapacity"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[ResourceSkuLocationInfo]"}, + "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, } def __init__( @@ -5936,10 +5573,10 @@ def __init__( resource_type: Optional[str] = None, name: Optional[str] = None, tier: Optional[str] = None, - capacity: Optional["SkuCapacity"] = None, + capacity: Optional["_models.SkuCapacity"] = None, locations: Optional[List[str]] = None, - location_info: Optional[List["ResourceSkuLocationInfo"]] = None, - restrictions: Optional[List["ResourceSkuRestrictions"]] = None, + location_info: Optional[List["_models.ResourceSkuLocationInfo"]] = None, + restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None, **kwargs ): """ @@ -5962,7 +5599,7 @@ def __init__( :paramtype restrictions: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceSkuRestrictions] """ - super(ResourceSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.name = name self.tier = tier @@ -5972,7 +5609,7 @@ def __init__( self.restrictions = restrictions -class ResourceSkuCapabilities(msrest.serialization.Model): +class ResourceSkuCapabilities(_serialization.Model): """ResourceSkuCapabilities. :ivar name: Gets an invariant to describe the feature. @@ -5982,29 +5619,23 @@ class ResourceSkuCapabilities(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: Gets an invariant to describe the feature. :paramtype name: str :keyword value: Gets an invariant if the feature is measured by quantity. :paramtype value: str """ - super(ResourceSkuCapabilities, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class ResourceSkuCollection(msrest.serialization.Model): +class ResourceSkuCollection(_serialization.Model): """Object that includes an array of Azure Spring Cloud SKU and a possible link for next set. :ivar value: Collection of resource SKU. @@ -6015,16 +5646,12 @@ class ResourceSkuCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ResourceSku"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ResourceSku"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of resource SKU. @@ -6033,12 +5660,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ResourceSkuCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ResourceSkuLocationInfo(msrest.serialization.Model): +class ResourceSkuLocationInfo(_serialization.Model): """Locations and availability zones where the SKU is available. :ivar location: Gets location of the SKU. @@ -6051,9 +5678,9 @@ class ResourceSkuLocationInfo(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'zone_details': {'key': 'zoneDetails', 'type': '[ResourceSkuZoneDetails]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "zone_details": {"key": "zoneDetails", "type": "[ResourceSkuZoneDetails]"}, } def __init__( @@ -6061,7 +5688,7 @@ def __init__( *, location: Optional[str] = None, zones: Optional[List[str]] = None, - zone_details: Optional[List["ResourceSkuZoneDetails"]] = None, + zone_details: Optional[List["_models.ResourceSkuZoneDetails"]] = None, **kwargs ): """ @@ -6073,13 +5700,13 @@ def __init__( :paramtype zone_details: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceSkuZoneDetails] """ - super(ResourceSkuLocationInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones self.zone_details = zone_details -class ResourceSkuRestrictionInfo(msrest.serialization.Model): +class ResourceSkuRestrictionInfo(_serialization.Model): """Information about the restriction where the SKU cannot be used. :ivar locations: Gets locations where the SKU is restricted. @@ -6089,33 +5716,27 @@ class ResourceSkuRestrictionInfo(msrest.serialization.Model): """ _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - locations: Optional[List[str]] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, locations: Optional[List[str]] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword locations: Gets locations where the SKU is restricted. :paramtype locations: list[str] :keyword zones: Gets list of availability zones where the SKU is restricted. :paramtype zones: list[str] """ - super(ResourceSkuRestrictionInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.locations = locations self.zones = zones -class ResourceSkuRestrictions(msrest.serialization.Model): +class ResourceSkuRestrictions(_serialization.Model): """Restrictions where the SKU cannot be used. - :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. Known + values are: "Location" and "Zone". :vartype type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceSkuRestrictionsType :ivar values: Gets the value of restrictions. If the restriction type is set to @@ -6126,31 +5747,30 @@ class ResourceSkuRestrictions(msrest.serialization.Model): :vartype restriction_info: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceSkuRestrictionInfo :ivar reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceSkuRestrictionsReasonCode """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'ResourceSkuRestrictionInfo'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "restriction_info": {"key": "restrictionInfo", "type": "ResourceSkuRestrictionInfo"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceSkuRestrictionsType"]] = None, + type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None, values: Optional[List[str]] = None, - restriction_info: Optional["ResourceSkuRestrictionInfo"] = None, - reason_code: Optional[Union[str, "ResourceSkuRestrictionsReasonCode"]] = None, + restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None, + reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None, **kwargs ): """ :keyword type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + Known values are: "Location" and "Zone". :paramtype type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceSkuRestrictionsType :keyword values: Gets the value of restrictions. If the restriction type is set to @@ -6161,19 +5781,18 @@ def __init__( :paramtype restriction_info: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceSkuRestrictionInfo :keyword reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceSkuRestrictionsReasonCode """ - super(ResourceSkuRestrictions, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.values = values self.restriction_info = restriction_info self.reason_code = reason_code -class ResourceSkuZoneDetails(msrest.serialization.Model): +class ResourceSkuZoneDetails(_serialization.Model): """Details of capabilities available to a SKU in specific zones. :ivar name: Gets the set of zones that the SKU is available in with the @@ -6186,15 +5805,15 @@ class ResourceSkuZoneDetails(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[ResourceSkuCapabilities]'}, + "name": {"key": "name", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, } def __init__( self, *, name: Optional[List[str]] = None, - capabilities: Optional[List["ResourceSkuCapabilities"]] = None, + capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None, **kwargs ): """ @@ -6206,12 +5825,12 @@ def __init__( :paramtype capabilities: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceSkuCapabilities] """ - super(ResourceSkuZoneDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.capabilities = capabilities -class ResourceUploadDefinition(msrest.serialization.Model): +class ResourceUploadDefinition(_serialization.Model): """Resource upload definition payload. :ivar relative_path: Source relative path. @@ -6221,29 +5840,23 @@ class ResourceUploadDefinition(msrest.serialization.Model): """ _attribute_map = { - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'upload_url': {'key': 'uploadUrl', 'type': 'str'}, + "relative_path": {"key": "relativePath", "type": "str"}, + "upload_url": {"key": "uploadUrl", "type": "str"}, } - def __init__( - self, - *, - relative_path: Optional[str] = None, - upload_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, relative_path: Optional[str] = None, upload_url: Optional[str] = None, **kwargs): """ :keyword relative_path: Source relative path. :paramtype relative_path: str :keyword upload_url: Upload URL. :paramtype upload_url: str """ - super(ResourceUploadDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.relative_path = relative_path self.upload_url = upload_url -class ServiceRegistryInstance(msrest.serialization.Model): +class ServiceRegistryInstance(_serialization.Model): """Collection of instances belong to the Service Registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -6255,33 +5868,29 @@ class ServiceRegistryInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServiceRegistryInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class ServiceRegistryProperties(msrest.serialization.Model): +class ServiceRegistryProperties(_serialization.Model): """Service Registry properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Service Registry. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Service Registry. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceRegistryProvisioningState :ivar resource_requests: The requested resource quantity for required CPU and Memory. @@ -6293,24 +5902,20 @@ class ServiceRegistryProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'resource_requests': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'ServiceRegistryResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[ServiceRegistryInstance]'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "ServiceRegistryResourceRequests"}, + "instances": {"key": "instances", "type": "[ServiceRegistryInstance]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServiceRegistryProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.resource_requests = None self.instances = None @@ -6335,36 +5940,31 @@ class ServiceRegistryResource(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': 'ServiceRegistryProperties'}, + "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": "ServiceRegistryProperties"}, } - def __init__( - self, - *, - properties: Optional["ServiceRegistryProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ServiceRegistryProperties"] = None, **kwargs): """ :keyword properties: Service Registry properties payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceRegistryProperties """ - super(ServiceRegistryResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ServiceRegistryResourceCollection(msrest.serialization.Model): +class ServiceRegistryResourceCollection(_serialization.Model): """Object that includes an array of Service Registry resources and a possible link for next set. :ivar value: Collection of Service Registry resources. @@ -6376,14 +5976,14 @@ class ServiceRegistryResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceRegistryResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServiceRegistryResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ServiceRegistryResource"]] = None, + value: Optional[List["_models.ServiceRegistryResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -6395,12 +5995,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ServiceRegistryResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServiceRegistryResourceRequests(msrest.serialization.Model): +class ServiceRegistryResourceRequests(_serialization.Model): """Resource request payload of Service Registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -6414,24 +6014,20 @@ class ServiceRegistryResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, - 'instance_count': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServiceRegistryResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None self.instance_count = None @@ -6452,42 +6048,35 @@ class TrackedResource(Resource): :vartype system_data: ~azure.mgmt.appplatform.v2022_03_01_preview.models.SystemData :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] """ _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -6507,8 +6096,7 @@ class ServiceResource(TrackedResource): :vartype system_data: ~azure.mgmt.appplatform.v2022_03_01_preview.models.SystemData :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] :ivar properties: Properties of the Service resource. :vartype properties: @@ -6518,21 +6106,21 @@ class ServiceResource(TrackedResource): """ _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ClusterResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "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"}, + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "ClusterResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( @@ -6540,15 +6128,15 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - properties: Optional["ClusterResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.ClusterResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] :keyword properties: Properties of the Service resource. :paramtype properties: @@ -6556,12 +6144,12 @@ def __init__( :keyword sku: Sku of the Service resource. :paramtype sku: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Sku """ - super(ServiceResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.properties = properties self.sku = sku -class ServiceResourceList(msrest.serialization.Model): +class ServiceResourceList(_serialization.Model): """Object that includes an array of Service resources and a possible link for next set. :ivar value: Collection of Service resources. @@ -6572,16 +6160,12 @@ class ServiceResourceList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ServiceResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ServiceResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Service resources. @@ -6590,12 +6174,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ServiceResourceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification payload. :ivar log_specifications: Specifications of the Log for Azure Monitoring. @@ -6607,15 +6191,15 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } def __init__( self, *, - log_specifications: Optional[List["LogSpecification"]] = None, - metric_specifications: Optional[List["MetricSpecification"]] = None, + log_specifications: Optional[List["_models.LogSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -6626,12 +6210,12 @@ def __init__( :paramtype metric_specifications: list[~azure.mgmt.appplatform.v2022_03_01_preview.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_specifications = log_specifications self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """Sku of Azure Spring Cloud. :ivar name: Name of the Sku. @@ -6643,19 +6227,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Optional[str] = "S0", - tier: Optional[str] = "Standard", - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: str = "S0", tier: str = "Standard", capacity: Optional[int] = None, **kwargs): """ :keyword name: Name of the Sku. :paramtype name: str @@ -6664,37 +6241,37 @@ def __init__( :keyword capacity: Current capacity of the target resource. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SkuCapacity(msrest.serialization.Model): +class SkuCapacity(_serialization.Model): """The SKU capacity. All required parameters must be populated in order to send to Azure. - :ivar minimum: Required. Gets or sets the minimum. + :ivar minimum: Gets or sets the minimum. Required. :vartype minimum: int :ivar maximum: Gets or sets the maximum. :vartype maximum: int :ivar default: Gets or sets the default. :vartype default: int - :ivar scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :ivar scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", and + "Automatic". :vartype scale_type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.SkuScaleType """ _validation = { - 'minimum': {'required': True}, + "minimum": {"required": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } def __init__( @@ -6703,21 +6280,21 @@ def __init__( minimum: int, maximum: Optional[int] = None, default: Optional[int] = None, - scale_type: Optional[Union[str, "SkuScaleType"]] = None, + scale_type: Optional[Union[str, "_models.SkuScaleType"]] = None, **kwargs ): """ - :keyword minimum: Required. Gets or sets the minimum. + :keyword minimum: Gets or sets the minimum. Required. :paramtype minimum: int :keyword maximum: Gets or sets the maximum. :paramtype maximum: int :keyword default: Gets or sets the default. :paramtype default: int - :keyword scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :keyword scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", + and "Automatic". :paramtype scale_type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.SkuScaleType """ - super(SkuCapacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.minimum = minimum self.maximum = maximum self.default = default @@ -6729,7 +6306,7 @@ class SourceUploadedUserSourceInfo(UploadedUserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -6744,15 +6321,15 @@ class SourceUploadedUserSourceInfo(UploadedUserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'artifact_selector': {'key': 'artifactSelector', 'type': 'str'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "artifact_selector": {"key": "artifactSelector", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, } def __init__( @@ -6776,13 +6353,13 @@ def __init__( :keyword runtime_version: Runtime version of the source file. :paramtype runtime_version: str """ - super(SourceUploadedUserSourceInfo, self).__init__(version=version, relative_path=relative_path, **kwargs) - self.type = 'Source' # type: str + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "Source" # type: str self.artifact_selector = artifact_selector self.runtime_version = runtime_version -class SsoProperties(msrest.serialization.Model): +class SsoProperties(_serialization.Model): """Single sign-on related configuration. :ivar scope: It defines the specific actions applications can be allowed to do on a user's @@ -6797,10 +6374,10 @@ class SsoProperties(msrest.serialization.Model): """ _attribute_map = { - 'scope': {'key': 'scope', 'type': '[str]'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'client_secret': {'key': 'clientSecret', 'type': 'str'}, - 'issuer_uri': {'key': 'issuerUri', 'type': 'str'}, + "scope": {"key": "scope", "type": "[str]"}, + "client_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, + "issuer_uri": {"key": "issuerUri", "type": "str"}, } def __init__( @@ -6823,14 +6400,14 @@ def __init__( :keyword issuer_uri: The URI of Issuer Identifier. :paramtype issuer_uri: str """ - super(SsoProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.scope = scope self.client_id = client_id self.client_secret = client_secret self.issuer_uri = issuer_uri -class StackProperties(msrest.serialization.Model): +class StackProperties(_serialization.Model): """KPack ClusterStack properties payload. :ivar id: Id of the ClusterStack. @@ -6840,16 +6417,12 @@ class StackProperties(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( - self, - *, - id: Optional[str] = None, - version: Optional[str] = None, - **kwargs + self, *, id: Optional[str] = None, version: Optional[str] = None, **kwargs # pylint: disable=redefined-builtin ): """ :keyword id: Id of the ClusterStack. @@ -6857,43 +6430,36 @@ def __init__( :keyword version: Version of the ClusterStack. :paramtype version: str """ - super(StackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.version = version -class StorageProperties(msrest.serialization.Model): +class StorageProperties(_serialization.Model): """Storage resource payload. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: StorageAccount. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + StorageAccount All required parameters must be populated in order to send to Azure. - :ivar storage_type: Required. The type of the storage.Constant filled by server. Possible - values include: "StorageAccount". + :ivar storage_type: The type of the storage. Required. "StorageAccount" :vartype storage_type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageType """ _validation = { - 'storage_type': {'required': True}, + "storage_type": {"required": True}, } _attribute_map = { - 'storage_type': {'key': 'storageType', 'type': 'str'}, + "storage_type": {"key": "storageType", "type": "str"}, } - _subtype_map = { - 'storage_type': {'StorageAccount': 'StorageAccount'} - } + _subtype_map = {"storage_type": {"StorageAccount": "StorageAccount"}} - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.storage_type = None # type: Optional[str] @@ -6902,42 +6468,35 @@ class StorageAccount(StorageProperties): All required parameters must be populated in order to send to Azure. - :ivar storage_type: Required. The type of the storage.Constant filled by server. Possible - values include: "StorageAccount". + :ivar storage_type: The type of the storage. Required. "StorageAccount" :vartype storage_type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageType - :ivar account_name: Required. The account name of the Azure Storage Account. + :ivar account_name: The account name of the Azure Storage Account. Required. :vartype account_name: str - :ivar account_key: Required. The account key of the Azure Storage Account. + :ivar account_key: The account key of the Azure Storage Account. Required. :vartype account_key: str """ _validation = { - 'storage_type': {'required': True}, - 'account_name': {'required': True}, - 'account_key': {'required': True}, + "storage_type": {"required": True}, + "account_name": {"required": True}, + "account_key": {"required": True}, } _attribute_map = { - 'storage_type': {'key': 'storageType', 'type': 'str'}, - 'account_name': {'key': 'accountName', 'type': 'str'}, - 'account_key': {'key': 'accountKey', 'type': 'str'}, + "storage_type": {"key": "storageType", "type": "str"}, + "account_name": {"key": "accountName", "type": "str"}, + "account_key": {"key": "accountKey", "type": "str"}, } - def __init__( - self, - *, - account_name: str, - account_key: str, - **kwargs - ): + def __init__(self, *, account_name: str, account_key: str, **kwargs): """ - :keyword account_name: Required. The account name of the Azure Storage Account. + :keyword account_name: The account name of the Azure Storage Account. Required. :paramtype account_name: str - :keyword account_key: Required. The account key of the Azure Storage Account. + :keyword account_key: The account key of the Azure Storage Account. Required. :paramtype account_key: str """ - super(StorageAccount, self).__init__(**kwargs) - self.storage_type = 'StorageAccount' # type: str + super().__init__(**kwargs) + self.storage_type = "StorageAccount" # type: str self.account_name = account_name self.account_key = account_key @@ -6960,35 +6519,30 @@ class StorageResource(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': 'StorageProperties'}, + "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": "StorageProperties"}, } - def __init__( - self, - *, - properties: Optional["StorageProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.StorageProperties"] = None, **kwargs): """ :keyword properties: Properties of the storage resource payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageProperties """ - super(StorageResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class StorageResourceCollection(msrest.serialization.Model): +class StorageResourceCollection(_serialization.Model): """Collection compose of storage resources list and a possible link for next page. :ivar value: The storage resources list. @@ -6998,16 +6552,12 @@ class StorageResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["StorageResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.StorageResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The storage resources list. @@ -7015,7 +6565,7 @@ def __init__( :keyword next_link: The link to next page of storage list. :paramtype next_link: str """ - super(StorageResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -7039,36 +6589,31 @@ class SupportedBuildpackResource(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': 'SupportedBuildpackResourceProperties'}, + "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": "SupportedBuildpackResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["SupportedBuildpackResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.SupportedBuildpackResourceProperties"] = None, **kwargs): """ :keyword properties: Supported buildpack resource properties. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.SupportedBuildpackResourceProperties """ - super(SupportedBuildpackResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class SupportedBuildpackResourceProperties(msrest.serialization.Model): +class SupportedBuildpackResourceProperties(_serialization.Model): """Supported buildpack resource properties. :ivar buildpack_id: The id of supported buildpack. @@ -7076,24 +6621,19 @@ class SupportedBuildpackResourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'buildpack_id': {'key': 'buildpackId', 'type': 'str'}, + "buildpack_id": {"key": "buildpackId", "type": "str"}, } - def __init__( - self, - *, - buildpack_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, buildpack_id: Optional[str] = None, **kwargs): """ :keyword buildpack_id: The id of supported buildpack. :paramtype buildpack_id: str """ - super(SupportedBuildpackResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.buildpack_id = buildpack_id -class SupportedBuildpacksCollection(msrest.serialization.Model): +class SupportedBuildpacksCollection(_serialization.Model): """Object that includes an array of supported buildpacks resources and a possible link for next set. :ivar value: Collection of supported buildpacks resources. @@ -7105,14 +6645,14 @@ class SupportedBuildpacksCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedBuildpackResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SupportedBuildpackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["SupportedBuildpackResource"]] = None, + value: Optional[List["_models.SupportedBuildpackResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -7124,19 +6664,19 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(SupportedBuildpacksCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SupportedRuntimeVersion(msrest.serialization.Model): +class SupportedRuntimeVersion(_serialization.Model): """Supported deployment runtime version descriptor. - :ivar value: The raw value which could be passed to deployment CRUD operations. Possible values - include: "Java_8", "Java_11", "Java_17", "NetCore_31". + :ivar value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", "Java_17", and "NetCore_31". :vartype value: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.SupportedRuntimeValue - :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). Known + values are: "Java" and ".NET Core". :vartype platform: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.SupportedRuntimePlatform :ivar version: The detailed version (major.minor) of the platform. @@ -7144,32 +6684,32 @@ class SupportedRuntimeVersion(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'platform': {'key': 'platform', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "platform": {"key": "platform", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - value: Optional[Union[str, "SupportedRuntimeValue"]] = None, - platform: Optional[Union[str, "SupportedRuntimePlatform"]] = None, + value: Optional[Union[str, "_models.SupportedRuntimeValue"]] = None, + platform: Optional[Union[str, "_models.SupportedRuntimePlatform"]] = None, version: Optional[str] = None, **kwargs ): """ - :keyword value: The raw value which could be passed to deployment CRUD operations. Possible - values include: "Java_8", "Java_11", "Java_17", "NetCore_31". + :keyword value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", "Java_17", and "NetCore_31". :paramtype value: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.SupportedRuntimeValue :keyword platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + Known values are: "Java" and ".NET Core". :paramtype platform: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.SupportedRuntimePlatform :keyword version: The detailed version (major.minor) of the platform. :paramtype version: str """ - super(SupportedRuntimeVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.platform = platform self.version = version @@ -7194,36 +6734,31 @@ class SupportedStackResource(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': 'SupportedStackResourceProperties'}, + "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": "SupportedStackResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["SupportedStackResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.SupportedStackResourceProperties"] = None, **kwargs): """ :keyword properties: Supported stack resource properties. :paramtype properties: ~azure.mgmt.appplatform.v2022_03_01_preview.models.SupportedStackResourceProperties """ - super(SupportedStackResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class SupportedStackResourceProperties(msrest.serialization.Model): +class SupportedStackResourceProperties(_serialization.Model): """Supported stack resource properties. :ivar stack_id: The id of supported stack. @@ -7233,29 +6768,23 @@ class SupportedStackResourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'stack_id': {'key': 'stackId', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "stack_id": {"key": "stackId", "type": "str"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - *, - stack_id: Optional[str] = None, - version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, stack_id: Optional[str] = None, version: Optional[str] = None, **kwargs): """ :keyword stack_id: The id of supported stack. :paramtype stack_id: str :keyword version: The version of supported stack. :paramtype version: str """ - super(SupportedStackResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.stack_id = stack_id self.version = version -class SupportedStacksCollection(msrest.serialization.Model): +class SupportedStacksCollection(_serialization.Model): """Object that includes an array of supported stacks resources and a possible link for next set. :ivar value: Collection of supported stacks resources. @@ -7266,14 +6795,14 @@ class SupportedStacksCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedStackResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SupportedStackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["SupportedStackResource"]] = None, + value: Optional[List["_models.SupportedStackResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -7285,26 +6814,26 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(SupportedStacksCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -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.appplatform.v2022_03_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.LastModifiedByType :ivar last_modified_at: The timestamp of resource modification (UTC). @@ -7312,44 +6841,44 @@ class SystemData(msrest.serialization.Model): """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "LastModifiedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.appplatform.v2022_03_01_preview.models.LastModifiedByType :keyword last_modified_at: The timestamp of resource modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -7358,7 +6887,7 @@ def __init__( self.last_modified_at = last_modified_at -class TemporaryDisk(msrest.serialization.Model): +class TemporaryDisk(_serialization.Model): """Temporary disk payload. :ivar size_in_gb: Size of the temporary disk in GB. @@ -7368,33 +6897,27 @@ class TemporaryDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 5, 'minimum': 0}, + "size_in_gb": {"maximum": 5, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = "/tmp", - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: str = "/tmp", **kwargs): """ :keyword size_in_gb: Size of the temporary disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the temporary disk. :paramtype mount_path: str """ - super(TemporaryDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.mount_path = mount_path -class TestKeys(msrest.serialization.Model): +class TestKeys(_serialization.Model): """Test keys payload. :ivar primary_key: Primary key. @@ -7410,11 +6933,11 @@ class TestKeys(msrest.serialization.Model): """ _attribute_map = { - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'primary_test_endpoint': {'key': 'primaryTestEndpoint', 'type': 'str'}, - 'secondary_test_endpoint': {'key': 'secondaryTestEndpoint', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "primary_test_endpoint": {"key": "primaryTestEndpoint", "type": "str"}, + "secondary_test_endpoint": {"key": "secondaryTestEndpoint", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, } def __init__( @@ -7439,7 +6962,7 @@ def __init__( :keyword enabled: Indicates whether the test endpoint feature enabled or not. :paramtype enabled: bool """ - super(TestKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_key = primary_key self.secondary_key = secondary_key self.primary_test_endpoint = primary_test_endpoint @@ -7447,7 +6970,7 @@ def __init__( self.enabled = enabled -class TriggeredBuildResult(msrest.serialization.Model): +class TriggeredBuildResult(_serialization.Model): """The build result triggered by a build. :ivar id: The unique build id of this build result. @@ -7455,24 +6978,19 @@ class TriggeredBuildResult(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The unique build id of this build result. :paramtype id: str """ - super(TriggeredBuildResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class UserAssignedManagedIdentity(msrest.serialization.Model): +class UserAssignedManagedIdentity(_serialization.Model): """The details of the user-assigned managed identity assigned to an App. Variables are only populated by the server, and will be ignored when sending a request. @@ -7484,27 +7002,23 @@ class UserAssignedManagedIdentity(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(UserAssignedManagedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class ValidationMessages(msrest.serialization.Model): +class ValidationMessages(_serialization.Model): """Validate messages of the configuration service git repositories. :ivar name: The name of the configuration service git repository. @@ -7514,23 +7028,17 @@ class ValidationMessages(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'messages': {'key': 'messages', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - messages: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs): """ :keyword name: The name of the configuration service git repository. :paramtype name: str :keyword messages: Detailed validation messages. :paramtype messages: list[str] """ - super(ValidationMessages, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.messages = messages diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/__init__.py index 0da100b4246c..57694a8d82f6 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/__init__.py @@ -30,28 +30,34 @@ from ._api_portals_operations import ApiPortalsOperations from ._api_portal_custom_domains_operations import ApiPortalCustomDomainsOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'ConfigurationServicesOperations', - 'ServiceRegistriesOperations', - 'BuildServiceOperations', - 'BuildpackBindingOperations', - 'BuildServiceBuilderOperations', - 'BuildServiceAgentPoolOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'StoragesOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', - 'GatewaysOperations', - 'GatewayRouteConfigsOperations', - 'GatewayCustomDomainsOperations', - 'ApiPortalsOperations', - 'ApiPortalCustomDomainsOperations', + "ServicesOperations", + "ConfigServersOperations", + "ConfigurationServicesOperations", + "ServiceRegistriesOperations", + "BuildServiceOperations", + "BuildpackBindingOperations", + "BuildServiceBuilderOperations", + "BuildServiceAgentPoolOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "StoragesOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", + "GatewaysOperations", + "GatewayRouteConfigsOperations", + "GatewayCustomDomainsOperations", + "ApiPortalsOperations", + "ApiPortalCustomDomainsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_api_portal_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_api_portal_custom_domains_operations.py index 83ed21ad8d2b..113bb2780666 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_api_portal_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_api_portal_custom_domains_operations.py @@ -6,282 +6,287 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, +def build_delete_request( resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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 ApiPortalCustomDomainsOperations(object): - """ApiPortalCustomDomainsOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApiPortalCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`api_portal_custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.ApiPortalCustomDomainResource": + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any + ) -> _models.ApiPortalCustomDomainResource: """Get the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiPortalCustomDomainResource, or the result of cls(response) + :return: ApiPortalCustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore def _create_or_update_initial( self, @@ -289,39 +294,55 @@ def _create_or_update_initial( service_name: str, api_portal_name: str, domain_name: str, - api_portal_custom_domain_resource: "_models.ApiPortalCustomDomainResource", + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], **kwargs: Any - ) -> "_models.ApiPortalCustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] + ) -> _models.ApiPortalCustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(api_portal_custom_domain_resource, 'ApiPortalCustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_custom_domain_resource, (IO, bytes)): + _content = api_portal_custom_domain_resource + else: + _json = self._serialize.body(api_portal_custom_domain_resource, "ApiPortalCustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: @@ -329,18 +350,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: _models.ApiPortalCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -349,24 +458,27 @@ def begin_create_or_update( service_name: str, api_portal_name: str, domain_name: str, - api_portal_custom_domain_resource: "_models.ApiPortalCustomDomainResource", + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.ApiPortalCustomDomainResource"]: + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: """Create or update the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_name: str :param api_portal_custom_domain_resource: The API portal custom domain for the create or update - operation. + operation. Is either a model type or a IO type. Required. :type api_portal_custom_domain_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -379,19 +491,21 @@ def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + 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, service_name=service_name, api_portal_name=api_portal_name, @@ -399,67 +513,75 @@ def begin_create_or_update( api_portal_custom_domain_resource=api_portal_custom_domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: @@ -469,28 +591,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_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. @@ -502,104 +618,122 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any - ) -> Iterable["_models.ApiPortalCustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> Iterable["_models.ApiPortalCustomDomainResource"]: """Handle requests to list all API portal custom domains. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiPortalCustomDomainResourceCollection or the - result of cls(response) + :return: An iterator like instance of either ApiPortalCustomDomainResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, api_portal_name=api_portal_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, - service_name=service_name, - api_portal_name=api_portal_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -613,10 +747,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 @@ -626,8 +758,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_api_portals_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_api_portals_operations.py index 978468a0daf1..36430e234f20 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_api_portals_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_api_portals_operations.py @@ -6,354 +6,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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, - service_name: str, - api_portal_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, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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, - service_name: str, - api_portal_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, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_domain_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - api_portal_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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 ApiPortalsOperations(object): - """ApiPortalsOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 ApiPortalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`api_portals` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any - ) -> "_models.ApiPortalResource": + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> _models.ApiPortalResource: """Get the API portal and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiPortalResource, or the result of cls(response) + :return: ApiPortalResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, api_portal_name: str, - api_portal_resource: "_models.ApiPortalResource", + api_portal_resource: Union[_models.ApiPortalResource, IO], **kwargs: Any - ) -> "_models.ApiPortalResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] + ) -> _models.ApiPortalResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(api_portal_resource, 'ApiPortalResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_resource, (IO, bytes)): + _content = api_portal_resource + else: + _json = self._serialize.body(api_portal_resource, "ApiPortalResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: @@ -361,18 +361,97 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: _models.ApiPortalResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -380,20 +459,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, api_portal_name: str, - api_portal_resource: "_models.ApiPortalResource", + api_portal_resource: Union[_models.ApiPortalResource, IO], **kwargs: Any - ) -> LROPoller["_models.ApiPortalResource"]: + ) -> LROPoller[_models.ApiPortalResource]: """Create the default API portal or update the existing API portal. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param api_portal_resource: The API portal for the create or update operation. + :param api_portal_resource: The API portal for the create or update operation. Is either a + model type or a IO type. Required. :type api_portal_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -406,84 +490,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + 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, service_name=service_name, api_portal_name=api_portal_name, api_portal_resource=api_portal_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, api_portal_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: @@ -493,25 +588,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the default API portal. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_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. @@ -523,98 +613,115 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, api_portal_name=api_portal_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.ApiPortalResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.ApiPortalResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiPortalResourceCollection or the result of - cls(response) + :return: An iterator like instance of either ApiPortalResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -628,10 +735,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 @@ -641,79 +746,159 @@ 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.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore - @distributed_trace + @overload def validate_domain( self, resource_group_name: str, service_name: str, api_portal_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the domains are valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_apps_operations.py index 6b71e487a5f2..c871b2fba89f 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_apps_operations.py @@ -6,387 +6,350 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, sync_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 sync_status is not None: - _query_parameters['syncStatus'] = _SERIALIZER.query("sync_status", sync_status, 'str') + _params["syncStatus"] = _SERIALIZER.query("sync_status", sync_status, "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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str +def build_list_request(resource_group_name: str, service_name: str, 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_resource_upload_url_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_set_active_deployments_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_set_active_deployments_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_validate_domain_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class AppsOperations(object): - """AppsOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`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 get( @@ -396,102 +359,125 @@ def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -499,21 +485,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -521,20 +586,24 @@ def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -547,84 +616,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -634,25 +714,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -664,83 +739,107 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -748,18 +847,97 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -767,20 +945,24 @@ def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -793,104 +975,120 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AppResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -904,10 +1102,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 @@ -917,112 +1113,129 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore def _set_active_deployments_initial( self, resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(active_deployment_collection, 'ActiveDeploymentCollection') - - request = build_set_active_deployments_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(active_deployment_collection, (IO, bytes)): + _content = active_deployment_collection + else: + _json = self._serialize.body(active_deployment_collection, "ActiveDeploymentCollection") + + request = build_set_active_deployments_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._set_active_deployments_initial.metadata['url'], + content=_content, + template_url=self._set_active_deployments_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]: @@ -1030,18 +1243,98 @@ def _set_active_deployments_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _set_active_deployments_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + _set_active_deployments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + @overload + def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: _models.ActiveDeploymentCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ActiveDeploymentCollection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_set_active_deployments( @@ -1049,21 +1342,25 @@ def begin_set_active_deployments( resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Set existing Deployment under the app as active. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param active_deployment_collection: A list of Deployment name to be active. + :param active_deployment_collection: A list of Deployment name to be active. Is either a model + type or a IO type. Required. :type active_deployment_collection: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.ActiveDeploymentCollection + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ActiveDeploymentCollection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1076,119 +1373,208 @@ def begin_set_active_deployments( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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._set_active_deployments_initial( + raw_result = self._set_active_deployments_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, active_deployment_collection=active_deployment_collection, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_set_active_deployments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + begin_set_active_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore - @distributed_trace + @overload def validate_domain( self, resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_bindings_operations.py index 4e59ea12b282..2f2fbad75edc 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_bindings_operations.py @@ -6,330 +6,310 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class BindingsOperations(object): - """BindingsOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +317,55 @@ def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -377,21 +373,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +481,27 @@ def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +514,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +536,75 @@ def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -518,28 +614,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -551,46 +641,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _update_initial( self, @@ -598,39 +696,55 @@ def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -638,18 +752,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +857,27 @@ def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +890,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +912,104 @@ def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +1023,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 @@ -816,8 +1034,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_build_service_agent_pool_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_build_service_agent_pool_operations.py index 15a896ee5e44..42d92f83de18 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_build_service_agent_pool_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_build_service_agent_pool_operations.py @@ -6,233 +6,246 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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, service_name: str, build_service_name: str, agent_pool_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_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_update_put_request_initial( - subscription_id: str, +def build_update_put_request( resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_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 - ) - -class BuildServiceAgentPoolOperations(object): - """BuildServiceAgentPoolOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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) + + +class BuildServiceAgentPoolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`build_service_agent_pool` 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, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildServiceAgentPoolResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.BuildServiceAgentPoolResource"]: """List build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceAgentPoolResourceCollection or the - result of cls(response) + :return: An iterator like instance of either BuildServiceAgentPoolResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -246,10 +259,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 @@ -259,78 +270,78 @@ 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - agent_pool_name: str, - **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": + self, resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: """Get build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildServiceAgentPoolResource, or the result of cls(response) + :return: BuildServiceAgentPoolResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore def _update_put_initial( self, @@ -338,39 +349,55 @@ def _update_put_initial( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] + ) -> _models.BuildServiceAgentPoolResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(agent_pool_resource, 'BuildServiceAgentPoolResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(agent_pool_resource, (IO, bytes)): + _content = agent_pool_resource + else: + _json = self._serialize.body(agent_pool_resource, "BuildServiceAgentPoolResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -378,18 +405,104 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: _models.BuildServiceAgentPoolResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( @@ -398,23 +511,27 @@ def begin_update_put( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> LROPoller["_models.BuildServiceAgentPoolResource"]: + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: """Create or update build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str - :param agent_pool_resource: Parameters for the update operation. + :param agent_pool_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type agent_pool_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -427,19 +544,21 @@ def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceAgentPoolResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, @@ -447,29 +566,34 @@ def begin_update_put( agent_pool_resource=agent_pool_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_build_service_builder_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_build_service_builder_operations.py index 352dd8f81295..65c9283fabe4 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_build_service_builder_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_build_service_builder_operations.py @@ -6,282 +6,287 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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, +def build_delete_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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 BuildServiceBuilderOperations(object): - """BuildServiceBuilderOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BuildServiceBuilderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`build_service_builder` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> "_models.BuilderResource": + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.BuilderResource: """Get a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuilderResource, or the result of cls(response) + :return: BuilderResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore def _create_or_update_initial( self, @@ -289,39 +294,55 @@ def _create_or_update_initial( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> "_models.BuilderResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] + ) -> _models.BuilderResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(builder_resource, 'BuilderResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(builder_resource, (IO, bytes)): + _content = builder_resource + else: + _json = self._serialize.body(builder_resource, "BuilderResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -329,18 +350,103 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: _models.BuilderResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -349,22 +455,27 @@ def begin_create_or_update( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> LROPoller["_models.BuilderResource"]: + ) -> LROPoller[_models.BuilderResource]: """Create or update a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param builder_resource: The target builder for the create or update operation. - :type builder_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource + :param builder_resource: The target builder for the create or update operation. Is either a + model type or a IO type. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -377,19 +488,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -397,67 +510,75 @@ def begin_create_or_update( builder_resource=builder_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, build_service_name: str, builder_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -467,28 +588,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_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. @@ -500,104 +615,121 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuilderResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.BuilderResource"]: """List KPack builders result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuilderResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BuilderResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -611,10 +743,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 @@ -624,8 +754,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_build_service_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_build_service_operations.py index 4629634f8c15..5c5d1df18023 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_build_service_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_build_service_operations.py @@ -6,618 +6,613 @@ # Code generated 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 +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_build_services_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_build_service_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_builds_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_build_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_build_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_list_build_results_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_build_result_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, build_result_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), - "buildResultName": _SERIALIZER.url("build_result_name", build_result_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_name, "str"), + "buildResultName": _SERIALIZER.url("build_result_name", build_result_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_build_result_log_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, build_result_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), - "buildResultName": _SERIALIZER.url("build_result_name", build_result_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_name, "str"), + "buildResultName": _SERIALIZER.url("build_result_name", build_result_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_get_resource_upload_url_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_list_supported_buildpacks_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_supported_buildpack_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildpackName": _SERIALIZER.url("buildpack_name", buildpack_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildpackName": _SERIALIZER.url("buildpack_name", buildpack_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_supported_stacks_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_supported_stack_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "stackName": _SERIALIZER.url("stack_name", stack_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "stackName": _SERIALIZER.url("stack_name", stack_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 BuildServiceOperations(object): - """BuildServiceOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BuildServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`build_service` 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_build_services( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildServiceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.BuildService"]: """List build services resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceCollection or the result of - cls(response) + :return: An iterator like instance of either BuildService or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildServiceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildService] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_services_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_services.metadata['url'], + template_url=self.list_build_services.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_build_services_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -631,10 +626,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 @@ -644,131 +637,141 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_build_services.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore + list_build_services.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore @distributed_trace def get_build_service( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.BuildService": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.BuildService: """Get a build service resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildService, or the result of cls(response) + :return: BuildService or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildService - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildService"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildService] - request = build_get_build_service_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_service.metadata['url'], + template_url=self.get_build_service.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildService', pipeline_response) + deserialized = self._deserialize("BuildService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore - + get_build_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore @distributed_trace def list_builds( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.Build"]: """List KPack builds. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildCollection or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Build or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_builds_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_builds.metadata['url'], + template_url=self.list_builds.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_builds_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -782,10 +785,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 @@ -795,78 +796,146 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_builds.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore + list_builds.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore @distributed_trace def get_build( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> "_models.Build": + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> _models.Build: """Get a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - request = build_get_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build.metadata['url'], + template_url=self.get_build.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + get_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + + @overload + def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: _models.Build, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Build + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update_build( @@ -875,57 +944,77 @@ def create_or_update_build( service_name: str, build_service_name: str, build_name: str, - build: "_models.Build", + build: Union[_models.Build, IO], **kwargs: Any - ) -> "_models.Build": + ) -> _models.Build: """Create or update a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build: Parameters for the create or update operation. - :type build: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Build + :param build: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type build: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Build or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - _json = self._serialize.body(build, 'Build') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build, (IO, bytes)): + _content = build + else: + _json = self._serialize.body(build, "Build") request = build_create_or_update_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_build.metadata['url'], + content=_content, + template_url=self.create_or_update_build.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]: @@ -933,81 +1022,87 @@ def create_or_update_build( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore - + create_or_update_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore @distributed_trace def list_build_results( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildResultCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> Iterable["_models.BuildResult"]: """List KPack build results. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildResultCollection or the result of - cls(response) + :return: An iterator like instance of either BuildResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildResultCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_results_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_results.metadata['url'], + template_url=self.list_build_results.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_build_results_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - build_name=build_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1021,10 +1116,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 @@ -1034,11 +1127,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_build_results.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore + list_build_results.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore @distributed_trace def get_build_result( @@ -1049,67 +1140,74 @@ def get_build_result( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResult": + ) -> _models.BuildResult: """Get a KPack build result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResult, or the result of cls(response) + :return: BuildResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResult] - request = build_get_build_result_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result.metadata['url'], + template_url=self.get_build_result.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResult', pipeline_response) + deserialized = self._deserialize("BuildResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore - + get_build_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore @distributed_trace def get_build_result_log( @@ -1120,387 +1218,407 @@ def get_build_result_log( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResultLog": + ) -> _models.BuildResultLog: """Get a KPack build result log download URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResultLog, or the result of cls(response) + :return: BuildResultLog or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildResultLog - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultLog"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultLog] - request = build_get_build_result_log_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result_log.metadata['url'], + template_url=self.get_build_result_log.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResultLog', pipeline_response) + deserialized = self._deserialize("BuildResultLog", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result_log.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore - + get_build_result_log.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore @distributed_trace def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for build service, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore @distributed_trace def list_supported_buildpacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedBuildpacksCollection: """Get all supported buildpacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpacksCollection, or the result of cls(response) + :return: SupportedBuildpacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.SupportedBuildpacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpacksCollection] - request = build_list_supported_buildpacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_buildpacks.metadata['url'], + template_url=self.list_supported_buildpacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedBuildpacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_buildpacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore - + list_supported_buildpacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore @distributed_trace def get_supported_buildpack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - buildpack_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, **kwargs: Any + ) -> _models.SupportedBuildpackResource: """Get the supported buildpack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param buildpack_name: The name of the buildpack resource. + :param buildpack_name: The name of the buildpack resource. Required. :type buildpack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpackResource, or the result of cls(response) + :return: SupportedBuildpackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.SupportedBuildpackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpackResource] - request = build_get_supported_buildpack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, buildpack_name=buildpack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_buildpack.metadata['url'], + template_url=self.get_supported_buildpack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpackResource', pipeline_response) + deserialized = self._deserialize("SupportedBuildpackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_buildpack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore - + get_supported_buildpack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore @distributed_trace def list_supported_stacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedStacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedStacksCollection: """Get all supported stacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStacksCollection, or the result of cls(response) + :return: SupportedStacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.SupportedStacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStacksCollection] - request = build_list_supported_stacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_stacks.metadata['url'], + template_url=self.list_supported_stacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedStacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_stacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore - + list_supported_stacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore @distributed_trace def get_supported_stack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - stack_name: str, - **kwargs: Any - ) -> "_models.SupportedStackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, **kwargs: Any + ) -> _models.SupportedStackResource: """Get the supported stack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param stack_name: The name of the stack resource. + :param stack_name: The name of the stack resource. Required. :type stack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStackResource, or the result of cls(response) + :return: SupportedStackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.SupportedStackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStackResource] - request = build_get_supported_stack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, stack_name=stack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_stack.metadata['url'], + template_url=self.get_supported_stack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStackResource', pipeline_response) + deserialized = self._deserialize("SupportedStackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_stack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore - + get_supported_stack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_buildpack_binding_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_buildpack_binding_operations.py index 8df841baf9b2..c568224e5c06 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_buildpack_binding_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_buildpack_binding_operations.py @@ -6,223 +6,230 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, buildpack_binding_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), - "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, buildpack_binding_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), - "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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, +def build_delete_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, buildpack_binding_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), - "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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 BuildpackBindingOperations(object): - """BuildpackBindingOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BuildpackBindingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`buildpack_binding` 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( @@ -233,67 +240,74 @@ def get( builder_name: str, buildpack_binding_name: str, **kwargs: Any - ) -> "_models.BuildpackBindingResource": + ) -> _models.BuildpackBindingResource: """Get a buildpack binding by name. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildpackBindingResource, or the result of cls(response) + :return: BuildpackBindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore def _create_or_update_initial( self, @@ -302,40 +316,56 @@ def _create_or_update_initial( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: Union[_models.BuildpackBindingResource, IO], **kwargs: Any - ) -> "_models.BuildpackBindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] + ) -> _models.BuildpackBindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(buildpack_binding, 'BuildpackBindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(buildpack_binding, (IO, bytes)): + _content = buildpack_binding + else: + _json = self._serialize.body(buildpack_binding, "BuildpackBindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -343,20 +373,19 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, @@ -364,25 +393,31 @@ def begin_create_or_update( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: _models.BuildpackBindingResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.BuildpackBindingResource"]: + ) -> LROPoller[_models.BuildpackBindingResource]: """Create or update a buildpack binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. :type buildpack_binding: ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -395,19 +430,114 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] - 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, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. Is + either a model type or a IO type. Required. + :type buildpack_binding: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResource] + :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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -416,32 +546,37 @@ def begin_create_or_update( buildpack_binding=buildpack_binding, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -452,33 +587,41 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements buildpack_binding_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -488,11 +631,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, service_name: str, @@ -504,15 +646,15 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Operation to delete a Buildpack Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_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. @@ -524,110 +666,126 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildpackBindingResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> Iterable["_models.BuildpackBindingResource"]: """Handles requests to list all buildpack bindings in a builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildpackBindingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either BuildpackBindingResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, - service_name=service_name, - build_service_name=build_service_name, - builder_name=builder_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -641,10 +799,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 @@ -654,8 +810,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_certificates_operations.py index 9a6735a75051..4426c2d58dab 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_certificates_operations.py @@ -6,308 +6,317 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - 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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", 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.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'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 get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(certificate_resource, 'CertificateResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -315,21 +324,101 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -337,21 +426,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> LROPoller["_models.CertificateResource"]: + ) -> LROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type certificate_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -364,84 +457,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -451,25 +555,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -481,98 +580,117 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +704,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 @@ -599,8 +715,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_config_servers_operations.py index 75f20a2a7aff..e2acf66425ed 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_config_servers_operations.py @@ -6,311 +6,311 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_validate_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ConfigServersOperations(object): - """ConfigServersOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -318,37 +318,115 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -361,86 +439,109 @@ def begin_update_put( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -448,37 +549,115 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -491,86 +670,109 @@ def begin_update_patch( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_settings, 'ConfigServerSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -578,37 +780,115 @@ def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerSettings + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -621,47 +901,54 @@ def begin_validate( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_configuration_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_configuration_services_operations.py index 07a5d39d5251..78b24c9b4f3d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_configuration_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_configuration_services_operations.py @@ -6,354 +6,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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, - service_name: str, - configuration_service_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, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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, - service_name: str, - configuration_service_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, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - configuration_service_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_validate_request( + resource_group_name: str, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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 ConfigurationServicesOperations(object): - """ConfigurationServicesOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 ConfigurationServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`configuration_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any - ) -> "_models.ConfigurationServiceResource": + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> _models.ConfigurationServiceResource: """Get the Application Configuration Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigurationServiceResource, or the result of cls(response) + :return: ConfigurationServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] + ) -> _models.ConfigurationServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(configuration_service_resource, 'ConfigurationServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_service_resource, (IO, bytes)): + _content = configuration_service_resource + else: + _json = self._serialize.body(configuration_service_resource, "ConfigurationServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -361,18 +361,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: _models.ConfigurationServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -380,22 +462,26 @@ def begin_create_or_update( resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigurationServiceResource"]: + ) -> LROPoller[_models.ConfigurationServiceResource]: """Create the default Application Configuration Service or update the existing Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param configuration_service_resource: Parameters for the update operation. + :param configuration_service_resource: Parameters for the update operation. Is either a model + type or a IO type. Required. :type configuration_service_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -408,84 +494,95 @@ def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + 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, service_name=service_name, configuration_service_name=configuration_service_name, configuration_service_resource=configuration_service_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, configuration_service_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -495,25 +592,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any ) -> LROPoller[None]: """Disable the default Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_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. @@ -525,98 +617,118 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, configuration_service_name=configuration_service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.ConfigurationServiceResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.ConfigurationServiceResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationServiceResourceCollection or the - result of cls(response) + :return: An iterator like instance of either ConfigurationServiceResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -630,10 +742,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 @@ -643,49 +753,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore def _validate_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] + ) -> _models.ConfigurationServiceSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(settings, 'ConfigurationServiceSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(settings, (IO, bytes)): + _content = settings + else: + _json = self._serialize.body(settings, "ConfigurationServiceSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -693,18 +817,97 @@ def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: _models.ConfigurationServiceSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_validate( @@ -712,20 +915,25 @@ def begin_validate( resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigurationServiceSettingsValidateResult"]: + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: """Check if the Application Configuration Service settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param settings: Application Configuration Service settings to be validated. + :param settings: Application Configuration Service settings to be validated. Is either a model + type or a IO type. Required. :type settings: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceSettings + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -738,48 +946,55 @@ def begin_validate( ConfigurationServiceSettingsValidateResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ConfigurationServiceSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + 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._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, settings=settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_custom_domains_operations.py index d3acd61a5e85..ec1b54b22831 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_custom_domains_operations.py @@ -6,330 +6,310 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class CustomDomainsOperations(object): - """CustomDomainsOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +317,55 @@ def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -377,21 +373,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +481,27 @@ def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +514,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +536,75 @@ def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -518,28 +614,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -551,46 +641,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _update_initial( self, @@ -598,39 +696,55 @@ def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -638,18 +752,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +857,27 @@ def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +890,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +912,105 @@ def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +1024,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 @@ -816,8 +1035,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_deployments_operations.py index 173c689fdf2c..7787624195a8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_deployments_operations.py @@ -6,678 +6,667 @@ # Code generated 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, List, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_delete_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_for_cluster_request( - subscription_id: str, resource_group_name: str, service_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_start_request_initial( - subscription_id: str, +def build_start_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_stop_request_initial( - subscription_id: str, +def build_stop_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request_initial( - subscription_id: str, +def build_restart_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_get_log_file_url_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_generate_heap_dump_request_initial( - subscription_id: str, +def build_generate_heap_dump_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_generate_thread_dump_request_initial( - subscription_id: str, +def build_generate_thread_dump_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_start_jfr_request_initial( - subscription_id: str, +def build_start_jfr_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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 DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( self, @@ -685,39 +674,55 @@ def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -725,21 +730,107 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -748,23 +839,27 @@ def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -777,19 +872,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -797,67 +894,75 @@ def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -867,28 +972,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -900,46 +999,54 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _update_initial( self, @@ -947,39 +1054,55 @@ def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -987,18 +1110,104 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -1007,23 +1216,27 @@ def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1036,19 +1249,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -1056,32 +1271,37 @@ def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -1091,60 +1311,72 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + ) -> Iterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1158,10 +1390,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 @@ -1171,69 +1401,76 @@ 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1247,10 +1484,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 @@ -1260,46 +1495,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1309,28 +1545,22 @@ def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1342,81 +1572,92 @@ def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1426,28 +1667,22 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1459,81 +1694,92 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -1543,28 +1789,22 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace - def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1576,98 +1816,109 @@ def begin_restart( # 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1676,15 +1927,14 @@ def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1692,39 +1942,55 @@ def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statemen service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_heap_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_heap_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_heap_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_heap_dump_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]: @@ -1734,33 +2000,119 @@ def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _generate_heap_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + _generate_heap_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + @overload + def begin_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_heap_dump( # pylint: disable=inconsistent-return-statements + def begin_generate_heap_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Generate Heap Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1771,19 +2123,21 @@ def begin_generate_heap_dump( # 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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._generate_heap_dump_initial( + raw_result = self._generate_heap_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1791,29 +2145,35 @@ def begin_generate_heap_dump( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_generate_heap_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + begin_generate_heap_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1821,39 +2181,55 @@ def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statem service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_thread_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_thread_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_thread_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_thread_dump_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]: @@ -1863,33 +2239,119 @@ def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _generate_thread_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + _generate_thread_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + @overload + def begin_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_thread_dump( # pylint: disable=inconsistent-return-statements + def begin_generate_thread_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Generate Thread Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1900,19 +2362,21 @@ def begin_generate_thread_dump( # pylint: disable=inconsistent-return-statement 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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._generate_thread_dump_initial( + raw_result = self._generate_thread_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1920,29 +2384,35 @@ def begin_generate_thread_dump( # pylint: disable=inconsistent-return-statement diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_generate_thread_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + begin_generate_thread_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore def _start_jfr_initial( # pylint: disable=inconsistent-return-statements self, @@ -1950,39 +2420,55 @@ def _start_jfr_initial( # pylint: disable=inconsistent-return-statements service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_start_jfr_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_start_jfr_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._start_jfr_initial.metadata['url'], + content=_content, + template_url=self._start_jfr_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]: @@ -1992,33 +2478,119 @@ def _start_jfr_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_jfr_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + _start_jfr_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + @overload + def begin_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_start_jfr( # pylint: disable=inconsistent-return-statements + def begin_start_jfr( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Start JFR. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_03_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2029,19 +2601,21 @@ def begin_start_jfr( # 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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._start_jfr_initial( + raw_result = self._start_jfr_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -2049,26 +2623,32 @@ def begin_start_jfr( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start_jfr.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + begin_start_jfr.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_gateway_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_gateway_custom_domains_operations.py index 08db59d600ad..66660f509e5d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_gateway_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_gateway_custom_domains_operations.py @@ -6,282 +6,287 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, +def build_delete_request( resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewayCustomDomainsOperations(object): - """GatewayCustomDomainsOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class GatewayCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`gateway_custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.GatewayCustomDomainResource": + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any + ) -> _models.GatewayCustomDomainResource: """Get the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayCustomDomainResource, or the result of cls(response) + :return: GatewayCustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore def _create_or_update_initial( self, @@ -289,39 +294,55 @@ def _create_or_update_initial( service_name: str, gateway_name: str, domain_name: str, - gateway_custom_domain_resource: "_models.GatewayCustomDomainResource", + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], **kwargs: Any - ) -> "_models.GatewayCustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] + ) -> _models.GatewayCustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_custom_domain_resource, 'GatewayCustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_custom_domain_resource, (IO, bytes)): + _content = gateway_custom_domain_resource + else: + _json = self._serialize.body(gateway_custom_domain_resource, "GatewayCustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: @@ -329,18 +350,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: _models.GatewayCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayCustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayCustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -349,24 +458,27 @@ def begin_create_or_update( service_name: str, gateway_name: str, domain_name: str, - gateway_custom_domain_resource: "_models.GatewayCustomDomainResource", + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.GatewayCustomDomainResource"]: + ) -> LROPoller[_models.GatewayCustomDomainResource]: """Create or update the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_name: str :param gateway_custom_domain_resource: The gateway custom domain resource for the create or - update operation. + update operation. Is either a model type or a IO type. Required. :type gateway_custom_domain_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -379,19 +491,21 @@ def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + 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, service_name=service_name, gateway_name=gateway_name, @@ -399,67 +513,75 @@ def begin_create_or_update( gateway_custom_domain_resource=gateway_custom_domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_name: str, domain_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: @@ -469,28 +591,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_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. @@ -502,104 +618,122 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> Iterable["_models.GatewayCustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> Iterable["_models.GatewayCustomDomainResource"]: """Handle requests to list all Spring Cloud Gateway custom domains. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayCustomDomainResourceCollection or the - result of cls(response) + :return: An iterator like instance of either GatewayCustomDomainResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, gateway_name=gateway_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, - service_name=service_name, - gateway_name=gateway_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -613,10 +747,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 @@ -626,8 +758,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_gateway_route_configs_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_gateway_route_configs_operations.py index 902e344daad8..a35ef7e160e8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_gateway_route_configs_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_gateway_route_configs_operations.py @@ -6,282 +6,287 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "routeConfigName": _SERIALIZER.url("route_config_name", route_config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_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_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "routeConfigName": _SERIALIZER.url("route_config_name", route_config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_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_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "routeConfigName": _SERIALIZER.url("route_config_name", route_config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_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="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewayRouteConfigsOperations(object): - """GatewayRouteConfigsOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class GatewayRouteConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`gateway_route_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 get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any - ) -> "_models.GatewayRouteConfigResource": + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any + ) -> _models.GatewayRouteConfigResource: """Get the Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayRouteConfigResource, or the result of cls(response) + :return: GatewayRouteConfigResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore def _create_or_update_initial( self, @@ -289,39 +294,55 @@ def _create_or_update_initial( service_name: str, gateway_name: str, route_config_name: str, - gateway_route_config_resource: "_models.GatewayRouteConfigResource", + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], **kwargs: Any - ) -> "_models.GatewayRouteConfigResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] + ) -> _models.GatewayRouteConfigResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_route_config_resource, 'GatewayRouteConfigResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_route_config_resource, (IO, bytes)): + _content = gateway_route_config_resource + else: + _json = self._serialize.body(gateway_route_config_resource, "GatewayRouteConfigResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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]: @@ -329,18 +350,108 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: _models.GatewayRouteConfigResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayRouteConfigResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayRouteConfigResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -349,25 +460,28 @@ def begin_create_or_update( service_name: str, gateway_name: str, route_config_name: str, - gateway_route_config_resource: "_models.GatewayRouteConfigResource", + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], **kwargs: Any - ) -> LROPoller["_models.GatewayRouteConfigResource"]: + ) -> LROPoller[_models.GatewayRouteConfigResource]: """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_name: str :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or - update operation. + update operation. Is either a model type or a IO type. Required. :type gateway_route_config_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -380,19 +494,21 @@ def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + 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, service_name=service_name, gateway_name=gateway_name, @@ -400,67 +516,75 @@ def begin_create_or_update( gateway_route_config_resource=gateway_route_config_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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]: @@ -470,28 +594,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the Spring Cloud Gateway route config. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_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. @@ -503,104 +621,122 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> Iterable["_models.GatewayRouteConfigResourceCollection"]: + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> Iterable["_models.GatewayRouteConfigResource"]: """Handle requests to list all Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayRouteConfigResourceCollection or the result - of cls(response) + :return: An iterator like instance of either GatewayRouteConfigResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, gateway_name=gateway_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, - service_name=service_name, - gateway_name=gateway_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -614,10 +750,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 @@ -627,8 +761,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_gateways_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_gateways_operations.py index 010df16f444d..fe2806001f0f 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_gateways_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_gateways_operations.py @@ -6,354 +6,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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, - service_name: str, - gateway_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, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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, - service_name: str, - gateway_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, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_domain_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - gateway_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewaysOperations(object): - """GatewaysOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 GatewaysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`gateways` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> "_models.GatewayResource": + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> _models.GatewayResource: """Get the Spring Cloud Gateway and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayResource, or the result of cls(response) + :return: GatewayResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, gateway_name: str, - gateway_resource: "_models.GatewayResource", + gateway_resource: Union[_models.GatewayResource, IO], **kwargs: Any - ) -> "_models.GatewayResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] + ) -> _models.GatewayResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_resource, 'GatewayResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_resource, (IO, bytes)): + _content = gateway_resource + else: + _json = self._serialize.body(gateway_resource, "GatewayResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: @@ -361,18 +361,97 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: _models.GatewayResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -380,20 +459,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, gateway_name: str, - gateway_resource: "_models.GatewayResource", + gateway_resource: Union[_models.GatewayResource, IO], **kwargs: Any - ) -> LROPoller["_models.GatewayResource"]: + ) -> LROPoller[_models.GatewayResource]: """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param gateway_resource: The gateway for the create or update operation. - :type gateway_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource + :param gateway_resource: The gateway for the create or update operation. Is either a model type + or a IO type. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -406,84 +490,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + 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, service_name=service_name, gateway_name=gateway_name, gateway_resource=gateway_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: @@ -493,25 +588,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any ) -> LROPoller[None]: """Disable the default Spring Cloud Gateway. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_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. @@ -523,98 +613,115 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, gateway_name=gateway_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.GatewayResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.GatewayResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayResourceCollection or the result of - cls(response) + :return: An iterator like instance of either GatewayResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -628,10 +735,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 @@ -641,79 +746,159 @@ 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.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore - @distributed_trace + @overload def validate_domain( self, resource_group_name: str, service_name: str, gateway_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the domains are valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_monitoring_settings_operations.py index a99be97950ea..5b307772efc5 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_monitoring_settings_operations.py @@ -6,267 +6,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 MonitoringSettingsOperations(object): - """MonitoringSettingsOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -274,37 +282,115 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -317,86 +403,109 @@ def begin_update_put( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -404,37 +513,115 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation 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,47 +634,54 @@ def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_operations.py index 22e18df017b5..f78d21a05669 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_operations.py @@ -6,111 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - accept = "application/json" +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,10 +147,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 +158,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_runtime_versions_operations.py index 108f5a18aefd..637576255566 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_runtime_versions_operations.py @@ -6,117 +6,128 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from 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 -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_runtime_versions_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - accept = "application/json" +def build_list_runtime_versions_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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/runtimeVersions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 RuntimeVersionsOperations(object): - """RuntimeVersionsOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_service_registries_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_service_registries_operations.py index fd66664a624c..c3b97afbf506 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_service_registries_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_service_registries_operations.py @@ -6,294 +6,297 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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, - service_name: str, - service_registry_name: str, - **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, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + _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, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ServiceRegistriesOperations(object): - """ServiceRegistriesOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServiceRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`service_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: """Get the Service Registry and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceRegistryResource, or the result of cls(response) + :return: ServiceRegistryResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceRegistryResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._create_or_update_initial.metadata['url'], + 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]: @@ -301,35 +304,30 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> LROPoller["_models.ServiceRegistryResource"]: + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> LROPoller[_models.ServiceRegistryResource]: """Create the default Service Registry or update the existing Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -343,81 +341,92 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceRegistryResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: @@ -427,25 +436,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> LROPoller[None]: """Disable the default Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -457,98 +461,118 @@ 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-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.ServiceRegistryResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.ServiceRegistryResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceRegistryResourceCollection or the result of + :return: An iterator like instance of either ServiceRegistryResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceRegistryResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceRegistryResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -562,10 +586,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 @@ -575,8 +597,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_services_operations.py index 5bb8285dc5ff..95ef80c0f8fe 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_services_operations.py @@ -6,636 +6,594 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_test_keys_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_regenerate_test_key_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/regenerateTestKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_disable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_enable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_stop_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_stop_request(resource_group_name: str, service_name: str, 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_start_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_check_name_availability_request( - subscription_id: str, - location: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "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 - ) - - -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 ServicesOperations(object): - """ServicesOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -643,39 +601,43 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -688,81 +650,162 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] + :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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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]: @@ -772,22 +815,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -799,80 +836,100 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -880,36 +937,40 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -922,220 +983,379 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] + :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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2022_03_01_preview.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2022_03_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -1145,98 +1365,104 @@ def disable_test_endpoint( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace - def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def enable_test_endpoint(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1246,22 +1472,16 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_stop(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Stop a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -1273,75 +1493,88 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1351,22 +1584,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_start(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Start a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -1378,147 +1605,229 @@ def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - @distributed_trace + @overload def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2022_03_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_03_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(availability_parameters, 'NameAvailabilityParameters') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1532,10 +1841,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 @@ -1545,58 +1852,68 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1610,10 +1927,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 @@ -1623,8 +1938,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_skus_operations.py index eac243f1d686..289a9a9ca86c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_skus_operations.py @@ -6,120 +6,140 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 SkusOperations(object): - """SkusOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) + :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -133,10 +153,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 @@ -146,8 +164,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_storages_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_storages_operations.py index bff9a55bc88a..3e6adcc3911a 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_storages_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_03_01_preview/operations/_storages_operations.py @@ -6,308 +6,317 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - storage_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, service_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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.AppPlatform/Spring/{serviceName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - 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, - service_name: str, - storage_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, service_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 StoragesOperations(object): - """StoragesOperations 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.appplatform.v2022_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class StoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_03_01_preview.AppPlatformManagementClient`'s + :attr:`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 get( - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any - ) -> "_models.StorageResource": + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> _models.StorageResource: """Get the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageResource, or the result of cls(response) + :return: StorageResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> "_models.StorageResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] + ) -> _models.StorageResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(storage_resource, 'StorageResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_resource, (IO, bytes)): + _content = storage_resource + else: + _json = self._serialize.body(storage_resource, "StorageResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -315,21 +324,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: _models.StorageResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -337,20 +425,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> LROPoller["_models.StorageResource"]: + ) -> LROPoller[_models.StorageResource]: """Create or update storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str - :param storage_resource: Parameters for the create or update operation. - :type storage_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource + :param storage_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -363,84 +456,95 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + 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, service_name=service_name, storage_name=storage_name, storage_resource=storage_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, storage_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-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, storage_name=storage_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]: @@ -450,25 +554,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_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. @@ -480,98 +579,115 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + 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, service_name=service_name, storage_name=storage_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, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.StorageResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.StorageResource"]: """List all the storages of one Azure Spring Cloud instance. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageResourceCollection or the result of - cls(response) + :return: An iterator like instance of either StorageResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_03_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01-preview") # 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", "2022-03-01-preview") + ) # type: Literal["2022-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -585,10 +701,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 @@ -598,8 +712,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/__init__.py index 41ec6d71ff7f..a6bfaa2de14d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_app_platform_management_client.py index f50df2a48906..cb9fe131e95b 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_app_platform_management_client.py @@ -9,20 +9,38 @@ 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 .._serialization import Deserializer, Serializer from ._configuration import AppPlatformManagementClientConfiguration -from .operations import AppsOperations, BindingsOperations, BuildServiceAgentPoolOperations, BuildServiceBuilderOperations, BuildServiceOperations, BuildpackBindingOperations, CertificatesOperations, ConfigServersOperations, ConfigurationServicesOperations, CustomDomainsOperations, DeploymentsOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServiceRegistriesOperations, ServicesOperations, SkusOperations +from .operations import ( + AppsOperations, + BindingsOperations, + BuildServiceAgentPoolOperations, + BuildServiceBuilderOperations, + BuildServiceOperations, + BuildpackBindingOperations, + CertificatesOperations, + ConfigServersOperations, + ConfigurationServicesOperations, + CustomDomainsOperations, + DeploymentsOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServiceRegistriesOperations, + ServicesOperations, + SkusOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Apps. :ivar services: ServicesOperations operations @@ -66,10 +84,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib azure.mgmt.appplatform.v2022_04_01.operations.RuntimeVersionsOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.appplatform.v2022_04_01.operations.SkusOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -87,7 +105,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -96,28 +116,37 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.configuration_services = ConfigurationServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.service_registries = ServiceRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_services = ConfigurationServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_registries = ServiceRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.build_service = BuildServiceOperations(self._client, self._config, self._serialize, self._deserialize) - self.buildpack_binding = BuildpackBindingOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_builder = BuildServiceBuilderOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_agent_pool = BuildServiceAgentPoolOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.buildpack_binding = BuildpackBindingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_builder = BuildServiceBuilderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_agent_pool = BuildServiceAgentPoolOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -126,7 +155,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_configuration.py index c776f7eae7d5..301d3a8fb034 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + api_version = kwargs.pop("api_version", "2022-04-01") # type: Literal["2022-04-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_metadata.json b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_metadata.json index 931e4cd83528..d94777696224 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_metadata.json +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}, \"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\": [\"AppPlatformManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -115,4 +115,4 @@ "runtime_versions": "RuntimeVersionsOperations", "skus": "SkusOperations" } -} \ No newline at end of file +} diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_vendor.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_vendor.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_version.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_version.py index e7ffc58c0429..92453d8691d9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_version.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.1.0" +VERSION = "6.1.0" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/__init__.py index 44ce4a5043f8..398c48287ad8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._app_platform_management_client import AppPlatformManagementClient -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/_app_platform_management_client.py index a1b2fd42062e..a03426a24ab4 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/_app_platform_management_client.py @@ -9,20 +9,38 @@ 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 AppPlatformManagementClientConfiguration -from .operations import AppsOperations, BindingsOperations, BuildServiceAgentPoolOperations, BuildServiceBuilderOperations, BuildServiceOperations, BuildpackBindingOperations, CertificatesOperations, ConfigServersOperations, ConfigurationServicesOperations, CustomDomainsOperations, DeploymentsOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServiceRegistriesOperations, ServicesOperations, SkusOperations +from .operations import ( + AppsOperations, + BindingsOperations, + BuildServiceAgentPoolOperations, + BuildServiceBuilderOperations, + BuildServiceOperations, + BuildpackBindingOperations, + CertificatesOperations, + ConfigServersOperations, + ConfigurationServicesOperations, + CustomDomainsOperations, + DeploymentsOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServiceRegistriesOperations, + ServicesOperations, + SkusOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Apps. :ivar services: ServicesOperations operations @@ -69,10 +87,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib azure.mgmt.appplatform.v2022_04_01.aio.operations.RuntimeVersionsOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.appplatform.v2022_04_01.aio.operations.SkusOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -90,7 +108,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -99,28 +119,37 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.configuration_services = ConfigurationServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.service_registries = ServiceRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_services = ConfigurationServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_registries = ServiceRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.build_service = BuildServiceOperations(self._client, self._config, self._serialize, self._deserialize) - self.buildpack_binding = BuildpackBindingOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_builder = BuildServiceBuilderOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_agent_pool = BuildServiceAgentPoolOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.buildpack_binding = BuildpackBindingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_builder = BuildServiceBuilderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_agent_pool = BuildServiceAgentPoolOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -129,7 +158,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/_configuration.py index 55d91609d509..9b413a15bc0e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + api_version = kwargs.pop("api_version", "2022-04-01") # type: Literal["2022-04-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/__init__.py index 152a0c3a0764..0567c6e67b60 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/__init__.py @@ -24,22 +24,28 @@ from ._runtime_versions_operations import RuntimeVersionsOperations from ._skus_operations import SkusOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'ConfigurationServicesOperations', - 'ServiceRegistriesOperations', - 'BuildServiceOperations', - 'BuildpackBindingOperations', - 'BuildServiceBuilderOperations', - 'BuildServiceAgentPoolOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', + "ServicesOperations", + "ConfigServersOperations", + "ConfigurationServicesOperations", + "ServiceRegistriesOperations", + "BuildServiceOperations", + "BuildpackBindingOperations", + "BuildServiceBuilderOperations", + "BuildServiceAgentPoolOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_apps_operations.py index 32b8e642d9b2..7d26a6091fdd 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_apps_operations.py @@ -6,46 +6,68 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._apps_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_get_resource_upload_url_request, build_list_request, build_set_active_deployments_request_initial, build_update_request_initial, build_validate_domain_request -T = TypeVar('T') +from ...operations._apps_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_get_resource_upload_url_request, + build_list_request, + build_set_active_deployments_request, + build_update_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AppsOperations: - """AppsOperations 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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`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_async async def get( @@ -55,102 +77,121 @@ async def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(app_resource, 'AppResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - 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(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -158,21 +199,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_04_01.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,20 +300,24 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_04_01.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_04_01.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -206,84 +330,89 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -293,25 +422,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -323,83 +447,101 @@ 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-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(app_resource, 'AppResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -407,18 +549,97 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_04_01.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -426,20 +647,24 @@ async def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_04_01.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_04_01.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -452,104 +677,114 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncIterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AppResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -563,10 +798,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 @@ -576,112 +809,125 @@ 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.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace_async async def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore async def _set_active_deployments_initial( self, resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(active_deployment_collection, 'ActiveDeploymentCollection') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_set_active_deployments_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(active_deployment_collection, (IO, bytes)): + _content = active_deployment_collection + else: + _json = self._serialize.body(active_deployment_collection, "ActiveDeploymentCollection") + + request = build_set_active_deployments_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._set_active_deployments_initial.metadata['url'], + content=_content, + template_url=self._set_active_deployments_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]: @@ -689,18 +935,98 @@ async def _set_active_deployments_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _set_active_deployments_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + _set_active_deployments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + @overload + async def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: _models.ActiveDeploymentCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_04_01.models.ActiveDeploymentCollection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_set_active_deployments( @@ -708,21 +1034,25 @@ async def begin_set_active_deployments( resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Set existing Deployment under the app as active. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param active_deployment_collection: A list of Deployment name to be active. + :param active_deployment_collection: A list of Deployment name to be active. Is either a model + type or a IO type. Required. :type active_deployment_collection: - ~azure.mgmt.appplatform.v2022_04_01.models.ActiveDeploymentCollection + ~azure.mgmt.appplatform.v2022_04_01.models.ActiveDeploymentCollection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -735,51 +1065,116 @@ async def begin_set_active_deployments( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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._set_active_deployments_initial( + raw_result = await self._set_active_deployments_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, active_deployment_collection=active_deployment_collection, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_set_active_deployments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + begin_set_active_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def validate_domain( @@ -787,66 +1182,84 @@ async def validate_domain( resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: Union[_models.CustomDomainValidatePayload, IO], **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainValidatePayload + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_bindings_operations.py index fa1a87d93b4e..0e762320db2e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_bindings_operations.py @@ -6,113 +6,132 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._bindings_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._bindings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BindingsOperations: - """BindingsOperations 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 BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +139,53 @@ async def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(binding_resource, 'BindingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - 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(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -160,21 +193,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +301,26 @@ async def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +333,19 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +353,71 @@ async def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -301,28 +427,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -334,46 +454,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _update_initial( self, @@ -381,39 +505,53 @@ async def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(binding_resource, 'BindingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -421,18 +559,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +664,26 @@ async def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +696,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +716,100 @@ async def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +823,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 @@ -599,8 +834,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_build_service_agent_pool_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_build_service_agent_pool_operations.py index 44f4ab35cbc5..d343671f4248 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_build_service_agent_pool_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_build_service_agent_pool_operations.py @@ -6,104 +6,129 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._build_service_agent_pool_operations import build_get_request, build_list_request, build_update_put_request_initial -T = TypeVar('T') +from ...operations._build_service_agent_pool_operations import ( + build_get_request, + build_list_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildServiceAgentPoolOperations: - """BuildServiceAgentPoolOperations 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 BuildServiceAgentPoolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`build_service_agent_pool` 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, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildServiceAgentPoolResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildServiceAgentPoolResource"]: """List build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceAgentPoolResourceCollection or the - result of cls(response) + :return: An iterator like instance of either BuildServiceAgentPoolResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -117,10 +142,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 @@ -130,78 +153,76 @@ 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - agent_pool_name: str, - **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": + self, resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: """Get build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildServiceAgentPoolResource, or the result of cls(response) + :return: BuildServiceAgentPoolResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore async def _update_put_initial( self, @@ -209,39 +230,53 @@ async def _update_put_initial( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] + ) -> _models.BuildServiceAgentPoolResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(agent_pool_resource, 'BuildServiceAgentPoolResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(agent_pool_resource, (IO, bytes)): + _content = agent_pool_resource + else: + _json = self._serialize.body(agent_pool_resource, "BuildServiceAgentPoolResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -249,18 +284,104 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: _models.BuildServiceAgentPoolResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( @@ -269,23 +390,27 @@ async def begin_update_put( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BuildServiceAgentPoolResource"]: + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: """Create or update build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str - :param agent_pool_resource: Parameters for the update operation. + :param agent_pool_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type agent_pool_resource: - ~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource + ~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -298,19 +423,19 @@ async def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, @@ -318,29 +443,32 @@ async def begin_update_put( agent_pool_resource=agent_pool_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_build_service_builder_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_build_service_builder_operations.py index 035d3d8564ee..0fb52f118614 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_build_service_builder_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_build_service_builder_operations.py @@ -6,113 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._build_service_builder_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._build_service_builder_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildServiceBuilderOperations: - """BuildServiceBuilderOperations 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 BuildServiceBuilderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`build_service_builder` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> "_models.BuilderResource": + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.BuilderResource: """Get a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuilderResource, or the result of cls(response) + :return: BuilderResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +138,53 @@ async def _create_or_update_initial( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> "_models.BuilderResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] + ) -> _models.BuilderResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(builder_resource, 'BuilderResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] - 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(builder_resource, (IO, bytes)): + _content = builder_resource + else: + _json = self._serialize.body(builder_resource, "BuilderResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -160,18 +192,103 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: _models.BuilderResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,22 +297,26 @@ async def begin_create_or_update( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BuilderResource"]: + ) -> AsyncLROPoller[_models.BuilderResource]: """Create or update a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param builder_resource: The target builder for the create or update operation. - :type builder_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource + :param builder_resource: The target builder for the create or update operation. Is either a + model type or a IO type. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -208,19 +329,19 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -228,67 +349,71 @@ async def begin_create_or_update( builder_resource=builder_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, build_service_name: str, builder_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -298,28 +423,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_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. @@ -331,104 +450,115 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuilderResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuilderResource"]: """List KPack builders result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuilderResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BuilderResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuilderResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -442,10 +572,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 @@ -455,8 +583,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_build_service_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_build_service_operations.py index 20a7b61d88b1..4905b1fe2c12 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_build_service_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_build_service_operations.py @@ -6,97 +6,133 @@ # Code generated 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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._build_service_operations import build_create_or_update_build_request, build_get_build_request, build_get_build_result_log_request, build_get_build_result_request, build_get_build_service_request, build_get_resource_upload_url_request, build_get_supported_buildpack_request, build_get_supported_stack_request, build_list_build_results_request, build_list_build_services_request, build_list_builds_request, build_list_supported_buildpacks_request, build_list_supported_stacks_request -T = TypeVar('T') +from ...operations._build_service_operations import ( + build_create_or_update_build_request, + build_get_build_request, + build_get_build_result_log_request, + build_get_build_result_request, + build_get_build_service_request, + build_get_resource_upload_url_request, + build_get_supported_buildpack_request, + build_get_supported_stack_request, + build_list_build_results_request, + build_list_build_services_request, + build_list_builds_request, + build_list_supported_buildpacks_request, + build_list_supported_stacks_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildServiceOperations: - """BuildServiceOperations 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 BuildServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`build_service` 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_build_services( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildServiceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildService"]: """List build services resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceCollection or the result of - cls(response) + :return: An iterator like instance of either BuildService or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildService] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_services_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_services.metadata['url'], + template_url=self.list_build_services.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_build_services_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -110,10 +146,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 @@ -123,131 +157,138 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_build_services.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore + list_build_services.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore @distributed_trace_async async def get_build_service( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.BuildService": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.BuildService: """Get a build service resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildService, or the result of cls(response) + :return: BuildService or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.BuildService - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildService"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildService] - request = build_get_build_service_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_service.metadata['url'], + template_url=self.get_build_service.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildService', pipeline_response) + deserialized = self._deserialize("BuildService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore - + get_build_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore @distributed_trace def list_builds( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Build"]: """List KPack builds. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildCollection or the result of cls(response) + :return: An iterator like instance of either Build or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_builds_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_builds.metadata['url'], + template_url=self.list_builds.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_builds_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -261,10 +302,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 @@ -274,78 +313,144 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_builds.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore + list_builds.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore @distributed_trace_async async def get_build( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> "_models.Build": + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> _models.Build: """Get a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - request = build_get_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build.metadata['url'], + template_url=self.get_build.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + get_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + @overload + async def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: _models.Build, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: ~azure.mgmt.appplatform.v2022_04_01.models.Build + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update_build( @@ -354,57 +459,75 @@ async def create_or_update_build( service_name: str, build_service_name: str, build_name: str, - build: "_models.Build", + build: Union[_models.Build, IO], **kwargs: Any - ) -> "_models.Build": + ) -> _models.Build: """Create or update a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build: Parameters for the create or update operation. - :type build: ~azure.mgmt.appplatform.v2022_04_01.models.Build + :param build: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type build: ~azure.mgmt.appplatform.v2022_04_01.models.Build or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - _json = self._serialize.body(build, 'Build') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build, (IO, bytes)): + _content = build + else: + _json = self._serialize.body(build, "Build") request = build_create_or_update_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_build.metadata['url'], + content=_content, + template_url=self.create_or_update_build.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]: @@ -412,81 +535,85 @@ async def create_or_update_build( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore - + create_or_update_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore @distributed_trace def list_build_results( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildResultCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildResult"]: """List KPack build results. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildResultCollection or the result of - cls(response) + :return: An iterator like instance of either BuildResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildResultCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_results_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_results.metadata['url'], + template_url=self.list_build_results.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_build_results_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - build_name=build_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -500,10 +627,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 @@ -513,11 +638,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_build_results.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore + list_build_results.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore @distributed_trace_async async def get_build_result( @@ -528,67 +651,72 @@ async def get_build_result( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResult": + ) -> _models.BuildResult: """Get a KPack build result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResult, or the result of cls(response) + :return: BuildResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.BuildResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResult] - request = build_get_build_result_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result.metadata['url'], + template_url=self.get_build_result.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResult', pipeline_response) + deserialized = self._deserialize("BuildResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore - + get_build_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore @distributed_trace_async async def get_build_result_log( @@ -599,387 +727,395 @@ async def get_build_result_log( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResultLog": + ) -> _models.BuildResultLog: """Get a KPack build result log download URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResultLog, or the result of cls(response) + :return: BuildResultLog or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.BuildResultLog - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultLog"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultLog] - request = build_get_build_result_log_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result_log.metadata['url'], + template_url=self.get_build_result_log.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResultLog', pipeline_response) + deserialized = self._deserialize("BuildResultLog", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result_log.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore - + get_build_result_log.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore @distributed_trace_async async def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for build service, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore @distributed_trace_async async def list_supported_buildpacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedBuildpacksCollection: """Get all supported buildpacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpacksCollection, or the result of cls(response) + :return: SupportedBuildpacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.SupportedBuildpacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpacksCollection] - request = build_list_supported_buildpacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_buildpacks.metadata['url'], + template_url=self.list_supported_buildpacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedBuildpacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_buildpacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore - + list_supported_buildpacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore @distributed_trace_async async def get_supported_buildpack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - buildpack_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, **kwargs: Any + ) -> _models.SupportedBuildpackResource: """Get the supported buildpack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param buildpack_name: The name of the buildpack resource. + :param buildpack_name: The name of the buildpack resource. Required. :type buildpack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpackResource, or the result of cls(response) + :return: SupportedBuildpackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.SupportedBuildpackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpackResource] - request = build_get_supported_buildpack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, buildpack_name=buildpack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_buildpack.metadata['url'], + template_url=self.get_supported_buildpack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpackResource', pipeline_response) + deserialized = self._deserialize("SupportedBuildpackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_buildpack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore - + get_supported_buildpack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore @distributed_trace_async async def list_supported_stacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedStacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedStacksCollection: """Get all supported stacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStacksCollection, or the result of cls(response) + :return: SupportedStacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.SupportedStacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStacksCollection] - request = build_list_supported_stacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_stacks.metadata['url'], + template_url=self.list_supported_stacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedStacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_stacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore - + list_supported_stacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore @distributed_trace_async async def get_supported_stack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - stack_name: str, - **kwargs: Any - ) -> "_models.SupportedStackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, **kwargs: Any + ) -> _models.SupportedStackResource: """Get the supported stack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param stack_name: The name of the stack resource. + :param stack_name: The name of the stack resource. Required. :type stack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStackResource, or the result of cls(response) + :return: SupportedStackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.SupportedStackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStackResource] - request = build_get_supported_stack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, stack_name=stack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_stack.metadata['url'], + template_url=self.get_supported_stack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStackResource', pipeline_response) + deserialized = self._deserialize("SupportedStackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_stack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore - + get_supported_stack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_buildpack_binding_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_buildpack_binding_operations.py index 2a82f70139d0..fe7ad87f14df 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_buildpack_binding_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_buildpack_binding_operations.py @@ -6,46 +6,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._buildpack_binding_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._buildpack_binding_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildpackBindingOperations: - """BuildpackBindingOperations 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 BuildpackBindingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`buildpack_binding` 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( @@ -56,67 +74,72 @@ async def get( builder_name: str, buildpack_binding_name: str, **kwargs: Any - ) -> "_models.BuildpackBindingResource": + ) -> _models.BuildpackBindingResource: """Get a buildpack binding by name. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildpackBindingResource, or the result of cls(response) + :return: BuildpackBindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore async def _create_or_update_initial( self, @@ -125,40 +148,54 @@ async def _create_or_update_initial( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: Union[_models.BuildpackBindingResource, IO], **kwargs: Any - ) -> "_models.BuildpackBindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] + ) -> _models.BuildpackBindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(buildpack_binding, 'BuildpackBindingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] - 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(buildpack_binding, (IO, bytes)): + _content = buildpack_binding + else: + _json = self._serialize.body(buildpack_binding, "BuildpackBindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -166,20 +203,19 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, @@ -187,24 +223,30 @@ async def begin_create_or_update( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: _models.BuildpackBindingResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.BuildpackBindingResource"]: + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: """Create or update a buildpack binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. :type buildpack_binding: ~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -217,19 +259,112 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] - 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, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildpackBindingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. Is + either a model type or a IO type. Required. + :type buildpack_binding: ~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildpackBindingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResource] + :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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -238,32 +373,35 @@ async def begin_create_or_update( buildpack_binding=buildpack_binding, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -274,33 +412,39 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements buildpack_binding_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -310,11 +454,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, service_name: str, @@ -326,15 +469,15 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Operation to delete a Buildpack Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_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. @@ -346,110 +489,120 @@ 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-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildpackBindingResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildpackBindingResource"]: """Handles requests to list all buildpack bindings in a builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildpackBindingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either BuildpackBindingResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, - service_name=service_name, - build_service_name=build_service_name, - builder_name=builder_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -463,10 +616,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 @@ -476,8 +627,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_certificates_operations.py index 0d13838915e3..3f99b482a007 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_certificates_operations.py @@ -6,147 +6,180 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'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_async async def get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_resource, 'CertificateResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - 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(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -154,21 +187,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -176,20 +288,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CertificateResource"]: + ) -> AsyncLROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. - :type certificate_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type certificate_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -202,84 +319,89 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -289,25 +411,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -319,98 +436,111 @@ 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-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -424,10 +554,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 @@ -437,8 +565,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_config_servers_operations.py index 2f3f8835732c..abb0cdd1f39e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_config_servers_operations.py @@ -6,139 +6,170 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._config_servers_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial, build_validate_request_initial -T = TypeVar('T') +from ...operations._config_servers_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConfigServersOperations: - """ConfigServersOperations 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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,36 +177,114 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -188,86 +297,103 @@ async def begin_update_put( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -275,36 +401,114 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -317,86 +521,103 @@ async def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(config_server_settings, 'ConfigServerSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -404,36 +625,114 @@ async def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerSettings + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -446,47 +745,52 @@ async def begin_validate( or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = await self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_configuration_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_configuration_services_operations.py index 4f4501b3c65c..da2ccbb03d1b 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_configuration_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_configuration_services_operations.py @@ -6,147 +6,181 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._configuration_services_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_validate_request_initial -T = TypeVar('T') +from ...operations._configuration_services_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConfigurationServicesOperations: - """ConfigurationServicesOperations 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 ConfigurationServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`configuration_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any - ) -> "_models.ConfigurationServiceResource": + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> _models.ConfigurationServiceResource: """Get the Application Configuration Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigurationServiceResource, or the result of cls(response) + :return: ConfigurationServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] + ) -> _models.ConfigurationServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(configuration_service_resource, 'ConfigurationServiceResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] - 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(configuration_service_resource, (IO, bytes)): + _content = configuration_service_resource + else: + _json = self._serialize.body(configuration_service_resource, "ConfigurationServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -154,18 +188,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: _models.ConfigurationServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -173,22 +289,26 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigurationServiceResource"]: + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: """Create the default Application Configuration Service or update the existing Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param configuration_service_resource: Parameters for the update operation. + :param configuration_service_resource: Parameters for the update operation. Is either a model + type or a IO type. Required. :type configuration_service_resource: - ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource + ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -201,84 +321,89 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + 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, service_name=service_name, configuration_service_name=configuration_service_name, configuration_service_resource=configuration_service_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, configuration_service_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -288,25 +413,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Disable the default Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -318,98 +438,112 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, configuration_service_name=configuration_service_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ConfigurationServiceResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationServiceResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationServiceResourceCollection or the - result of cls(response) + :return: An iterator like instance of either ConfigurationServiceResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -423,10 +557,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 @@ -436,49 +568,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.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore async def _validate_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] + ) -> _models.ConfigurationServiceSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(settings, 'ConfigurationServiceSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(settings, (IO, bytes)): + _content = settings + else: + _json = self._serialize.body(settings, "ConfigurationServiceSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -486,18 +630,97 @@ async def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: _models.ConfigurationServiceSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_validate( @@ -505,20 +728,24 @@ async def begin_validate( resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigurationServiceSettingsValidateResult"]: + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: """Check if the Application Configuration Service settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param settings: Application Configuration Service settings to be validated. - :type settings: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceSettings + :param settings: Application Configuration Service settings to be validated. Is either a model + type or a IO type. Required. + :type settings: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -531,48 +758,53 @@ async def begin_validate( ConfigurationServiceSettingsValidateResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + 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._validate_initial( + raw_result = await self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, settings=settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_custom_domains_operations.py index b5eb552c2fef..e9d62ff32c8d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_custom_domains_operations.py @@ -6,113 +6,132 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._custom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CustomDomainsOperations: - """CustomDomainsOperations 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 CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +139,53 @@ async def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(domain_resource, 'CustomDomainResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - 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(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -160,21 +193,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +301,26 @@ async def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. - :type domain_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +333,19 @@ async def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +353,71 @@ async def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -301,28 +427,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -334,46 +454,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _update_initial( self, @@ -381,39 +505,53 @@ async def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(domain_resource, 'CustomDomainResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -421,18 +559,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +664,26 @@ async def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. - :type domain_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +696,19 @@ async def begin_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +716,101 @@ async def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +824,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 @@ -599,8 +835,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_deployments_operations.py index 391901a14aaf..c2f029aad6ac 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_deployments_operations.py @@ -6,113 +6,140 @@ # Code generated 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, List, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._deployments_operations import build_create_or_update_request_initial, build_delete_request_initial, build_generate_heap_dump_request_initial, build_generate_thread_dump_request_initial, build_get_log_file_url_request, build_get_request, build_list_for_cluster_request, build_list_request, build_restart_request_initial, build_start_jfr_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._deployments_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_heap_dump_request, + build_generate_thread_dump_request, + build_get_log_file_url_request, + build_get_request, + build_list_for_cluster_request, + build_list_request, + build_restart_request, + build_start_jfr_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations 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 DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +147,53 @@ async def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(deployment_resource, 'DeploymentResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - 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(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -160,21 +201,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +309,26 @@ async def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. - :type deployment_resource: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +341,19 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +361,71 @@ async def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -301,28 +435,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -334,46 +462,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _update_initial( self, @@ -381,39 +513,53 @@ async def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(deployment_resource, 'DeploymentResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -421,18 +567,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +672,26 @@ async def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. - :type deployment_resource: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +704,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -489,32 +724,35 @@ async def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -524,60 +762,70 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + ) -> AsyncIterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -591,10 +839,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 @@ -604,69 +850,74 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -680,10 +931,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 @@ -693,46 +942,45 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -742,28 +990,22 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -775,81 +1017,86 @@ async def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -859,28 +1106,22 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -892,81 +1133,86 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore async def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -976,28 +1222,22 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async - async def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1009,98 +1249,103 @@ async def begin_restart( # 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-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async async def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1109,15 +1354,14 @@ async def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1125,39 +1369,53 @@ async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-st service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_generate_heap_dump_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_heap_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_heap_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_heap_dump_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]: @@ -1167,32 +1425,118 @@ async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - _generate_heap_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + _generate_heap_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + @overload + async def begin_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_heap_dump( # pylint: disable=inconsistent-return-statements + async def begin_generate_heap_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Generate Heap Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. - :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1203,19 +1547,19 @@ async def begin_generate_heap_dump( # pylint: disable=inconsistent-return-state 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[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", "2022-04-01")) # type: Literal["2022-04-01"] + 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._generate_heap_dump_initial( + raw_result = await self._generate_heap_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1223,29 +1567,33 @@ async def begin_generate_heap_dump( # pylint: disable=inconsistent-return-state diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **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_generate_heap_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + begin_generate_heap_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1253,39 +1601,53 @@ async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return- service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_generate_thread_dump_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_thread_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_thread_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_thread_dump_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]: @@ -1295,32 +1657,118 @@ async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return- if cls: return cls(pipeline_response, None, {}) - _generate_thread_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + _generate_thread_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + @overload + async def begin_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_thread_dump( # pylint: disable=inconsistent-return-statements + async def begin_generate_thread_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Generate Thread Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. - :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1331,19 +1779,19 @@ async def begin_generate_thread_dump( # pylint: disable=inconsistent-return-sta 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[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", "2022-04-01")) # type: Literal["2022-04-01"] + 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._generate_thread_dump_initial( + raw_result = await self._generate_thread_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1351,29 +1799,33 @@ async def begin_generate_thread_dump( # pylint: disable=inconsistent-return-sta diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **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_generate_thread_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + begin_generate_thread_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements self, @@ -1381,39 +1833,53 @@ async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_start_jfr_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_start_jfr_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._start_jfr_initial.metadata['url'], + content=_content, + template_url=self._start_jfr_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]: @@ -1423,32 +1889,118 @@ async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_jfr_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + _start_jfr_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + @overload + async def begin_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_start_jfr( # pylint: disable=inconsistent-return-statements + async def begin_start_jfr( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Start JFR. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. - :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1459,19 +2011,19 @@ async def begin_start_jfr( # 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[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", "2022-04-01")) # type: Literal["2022-04-01"] + 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._start_jfr_initial( + raw_result = await self._start_jfr_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1479,26 +2031,30 @@ async def begin_start_jfr( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **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_start_jfr.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + begin_start_jfr.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_monitoring_settings_operations.py index be988d6a0316..de71cc2e222d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_monitoring_settings_operations.py @@ -6,139 +6,171 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._monitoring_settings_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial -T = TypeVar('T') +from ...operations._monitoring_settings_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MonitoringSettingsOperations: - """MonitoringSettingsOperations 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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,37 +178,115 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,86 +299,103 @@ async def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -276,37 +403,115 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -319,47 +524,50 @@ async def begin_update_patch( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_operations.py index 4fcb09a84df7..ce188676c6de 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_operations.py @@ -6,82 +6,108 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.appplatform.v2022_04_01.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,10 +121,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 @@ -108,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_runtime_versions_operations.py index 8175b0d2faf5..a42229a77f41 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_runtime_versions_operations.py @@ -6,88 +6,102 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import 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._runtime_versions_operations import build_list_runtime_versions_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RuntimeVersionsOperations: - """RuntimeVersionsOperations 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 RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + async def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_service_registries_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_service_registries_operations.py index 6e74add2398b..435351d8b2e1 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_service_registries_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_service_registries_operations.py @@ -6,142 +6,163 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._service_registries_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._service_registries_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ServiceRegistriesOperations: - """ServiceRegistriesOperations 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 ServiceRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`service_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: """Get the Service Registry and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceRegistryResource, or the result of cls(response) + :return: ServiceRegistryResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.ServiceRegistryResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._create_or_update_initial.metadata['url'], + 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]: @@ -149,35 +170,30 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace_async async def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceRegistryResource"]: + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceRegistryResource]: """Create the default Service Registry or update the existing Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -191,81 +207,86 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ServiceRegistryResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: @@ -275,25 +296,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Disable the default Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -305,98 +321,112 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceRegistryResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServiceRegistryResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceRegistryResourceCollection or the result of + :return: An iterator like instance of either ServiceRegistryResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ServiceRegistryResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ServiceRegistryResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -410,10 +440,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 @@ -423,8 +451,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_services_operations.py index 5aa861619df3..c4c800051254 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_services_operations.py @@ -6,141 +6,176 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._services_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_disable_test_endpoint_request, build_enable_test_endpoint_request, build_get_request, build_list_by_subscription_request, build_list_request, build_list_test_keys_request, build_regenerate_test_key_request, build_update_request_initial -T = TypeVar('T') +from ...operations._services_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_disable_test_endpoint_request, + build_enable_test_endpoint_request, + build_get_request, + build_list_by_subscription_request, + build_list_request, + build_list_test_keys_request, + build_regenerate_test_key_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ServicesOperations: - """ServicesOperations 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 ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(resource, 'ServiceResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - 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(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -148,39 +183,43 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -193,81 +232,156 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] + :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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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]: @@ -277,22 +391,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -304,80 +412,94 @@ 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-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(resource, 'ServiceResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -385,36 +507,40 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -427,220 +553,369 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] + :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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + async def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_04_01.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2022_04_01.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2022_04_01.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace_async async def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -650,170 +925,241 @@ async def disable_test_endpoint( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace_async async def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - - @distributed_trace_async + @overload async def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_04_01.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(availability_parameters, 'NameAvailabilityParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -827,10 +1173,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 @@ -840,58 +1184,66 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -905,10 +1257,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 @@ -918,8 +1268,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_skus_operations.py index e78d8b07fc1f..d9ccd96bd5f8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/aio/operations/_skus_operations.py @@ -6,85 +6,109 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SkusOperations: - """SkusOperations 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 SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.aio.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) + :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -98,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -111,8 +133,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/__init__.py index 1964396464b5..b5222cc7e3ac 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/__init__.py @@ -137,191 +137,193 @@ from ._models_py3 import UserSourceInfo from ._models_py3 import ValidationMessages - -from ._app_platform_management_client_enums import ( - ActionType, - AppResourceProvisioningState, - BindingType, - BuildProvisioningState, - BuildResultProvisioningState, - BuildServiceProvisioningState, - BuilderProvisioningState, - BuildpackBindingProvisioningState, - ConfigServerState, - ConfigurationServiceProvisioningState, - CreatedByType, - DeploymentResourceProvisioningState, - DeploymentResourceStatus, - KPackBuildStageProvisioningState, - LastModifiedByType, - ManagedIdentityType, - MonitoringSettingState, - ProvisioningState, - ResourceSkuRestrictionsReasonCode, - ResourceSkuRestrictionsType, - ServiceRegistryProvisioningState, - SkuScaleType, - SupportedRuntimePlatform, - SupportedRuntimeValue, - TestKeyType, - TrafficDirection, -) +from ._app_platform_management_client_enums import ActionType +from ._app_platform_management_client_enums import AppResourceProvisioningState +from ._app_platform_management_client_enums import BindingType +from ._app_platform_management_client_enums import BuildProvisioningState +from ._app_platform_management_client_enums import BuildResultProvisioningState +from ._app_platform_management_client_enums import BuildServiceProvisioningState +from ._app_platform_management_client_enums import BuilderProvisioningState +from ._app_platform_management_client_enums import BuildpackBindingProvisioningState +from ._app_platform_management_client_enums import ConfigServerState +from ._app_platform_management_client_enums import ConfigurationServiceProvisioningState +from ._app_platform_management_client_enums import CreatedByType +from ._app_platform_management_client_enums import DeploymentResourceProvisioningState +from ._app_platform_management_client_enums import DeploymentResourceStatus +from ._app_platform_management_client_enums import KPackBuildStageProvisioningState +from ._app_platform_management_client_enums import LastModifiedByType +from ._app_platform_management_client_enums import ManagedIdentityType +from ._app_platform_management_client_enums import MonitoringSettingState +from ._app_platform_management_client_enums import ProvisioningState +from ._app_platform_management_client_enums import ResourceSkuRestrictionsReasonCode +from ._app_platform_management_client_enums import ResourceSkuRestrictionsType +from ._app_platform_management_client_enums import ServiceRegistryProvisioningState +from ._app_platform_management_client_enums import SkuScaleType +from ._app_platform_management_client_enums import SupportedRuntimePlatform +from ._app_platform_management_client_enums import SupportedRuntimeValue +from ._app_platform_management_client_enums import TestKeyType +from ._app_platform_management_client_enums import TrafficDirection +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__ = [ - 'ActiveDeploymentCollection', - 'AppResource', - 'AppResourceCollection', - 'AppResourceProperties', - 'ApplicationInsightsAgentVersions', - 'AvailableOperations', - 'AvailableRuntimeVersions', - 'BindingResource', - 'BindingResourceCollection', - 'BindingResourceProperties', - 'Build', - 'BuildCollection', - 'BuildProperties', - 'BuildResult', - 'BuildResultCollection', - 'BuildResultLog', - 'BuildResultProperties', - 'BuildResultUserSourceInfo', - 'BuildService', - 'BuildServiceAgentPoolProperties', - 'BuildServiceAgentPoolResource', - 'BuildServiceAgentPoolResourceCollection', - 'BuildServiceAgentPoolSizeProperties', - 'BuildServiceCollection', - 'BuildServiceProperties', - 'BuildServicePropertiesResourceRequests', - 'BuildStageProperties', - 'BuilderProperties', - 'BuilderResource', - 'BuilderResourceCollection', - 'BuildpackBindingLaunchProperties', - 'BuildpackBindingProperties', - 'BuildpackBindingResource', - 'BuildpackBindingResourceCollection', - 'BuildpackProperties', - 'BuildpacksGroupProperties', - 'CertificateProperties', - 'CertificateResource', - 'CertificateResourceCollection', - 'CloudErrorBody', - 'ClusterResourceProperties', - 'ConfigServerGitProperty', - 'ConfigServerProperties', - 'ConfigServerResource', - 'ConfigServerSettings', - 'ConfigServerSettingsErrorRecord', - 'ConfigServerSettingsValidateResult', - 'ConfigurationServiceGitProperty', - 'ConfigurationServiceGitPropertyValidateResult', - 'ConfigurationServiceGitRepository', - 'ConfigurationServiceInstance', - 'ConfigurationServiceProperties', - 'ConfigurationServiceResource', - 'ConfigurationServiceResourceCollection', - 'ConfigurationServiceResourceRequests', - 'ConfigurationServiceSettings', - 'ConfigurationServiceSettingsValidateResult', - 'ContentCertificateProperties', - 'CustomDomainProperties', - 'CustomDomainResource', - 'CustomDomainResourceCollection', - 'CustomDomainValidatePayload', - 'CustomDomainValidateResult', - 'DeploymentInstance', - 'DeploymentResource', - 'DeploymentResourceCollection', - 'DeploymentResourceProperties', - 'DeploymentSettings', - 'DiagnosticParameters', - 'Error', - 'GitPatternRepository', - 'JarUploadedUserSourceInfo', - 'KeyVaultCertificateProperties', - 'LoadedCertificate', - 'LogFileUrlResponse', - 'LogSpecification', - 'ManagedIdentityProperties', - 'MetricDimension', - 'MetricSpecification', - 'MonitoringSettingProperties', - 'MonitoringSettingResource', - 'NameAvailability', - 'NameAvailabilityParameters', - 'NetCoreZipUploadedUserSourceInfo', - 'NetworkProfile', - 'NetworkProfileOutboundIPs', - 'OperationDetail', - 'OperationDisplay', - 'OperationProperties', - 'PersistentDisk', - 'ProxyResource', - 'RegenerateTestKeyRequestPayload', - 'RequiredTraffic', - 'Resource', - 'ResourceRequests', - 'ResourceSku', - 'ResourceSkuCapabilities', - 'ResourceSkuCollection', - 'ResourceSkuLocationInfo', - 'ResourceSkuRestrictionInfo', - 'ResourceSkuRestrictions', - 'ResourceSkuZoneDetails', - 'ResourceUploadDefinition', - 'ServiceRegistryInstance', - 'ServiceRegistryProperties', - 'ServiceRegistryResource', - 'ServiceRegistryResourceCollection', - 'ServiceRegistryResourceRequests', - 'ServiceResource', - 'ServiceResourceList', - 'ServiceSpecification', - 'Sku', - 'SkuCapacity', - 'SourceUploadedUserSourceInfo', - 'StackProperties', - 'SupportedBuildpackResource', - 'SupportedBuildpackResourceProperties', - 'SupportedBuildpacksCollection', - 'SupportedRuntimeVersion', - 'SupportedStackResource', - 'SupportedStackResourceProperties', - 'SupportedStacksCollection', - 'SystemData', - 'TemporaryDisk', - 'TestKeys', - 'TrackedResource', - 'TriggeredBuildResult', - 'UploadedUserSourceInfo', - 'UserSourceInfo', - 'ValidationMessages', - 'ActionType', - 'AppResourceProvisioningState', - 'BindingType', - 'BuildProvisioningState', - 'BuildResultProvisioningState', - 'BuildServiceProvisioningState', - 'BuilderProvisioningState', - 'BuildpackBindingProvisioningState', - 'ConfigServerState', - 'ConfigurationServiceProvisioningState', - 'CreatedByType', - 'DeploymentResourceProvisioningState', - 'DeploymentResourceStatus', - 'KPackBuildStageProvisioningState', - 'LastModifiedByType', - 'ManagedIdentityType', - 'MonitoringSettingState', - 'ProvisioningState', - 'ResourceSkuRestrictionsReasonCode', - 'ResourceSkuRestrictionsType', - 'ServiceRegistryProvisioningState', - 'SkuScaleType', - 'SupportedRuntimePlatform', - 'SupportedRuntimeValue', - 'TestKeyType', - 'TrafficDirection', + "ActiveDeploymentCollection", + "AppResource", + "AppResourceCollection", + "AppResourceProperties", + "ApplicationInsightsAgentVersions", + "AvailableOperations", + "AvailableRuntimeVersions", + "BindingResource", + "BindingResourceCollection", + "BindingResourceProperties", + "Build", + "BuildCollection", + "BuildProperties", + "BuildResult", + "BuildResultCollection", + "BuildResultLog", + "BuildResultProperties", + "BuildResultUserSourceInfo", + "BuildService", + "BuildServiceAgentPoolProperties", + "BuildServiceAgentPoolResource", + "BuildServiceAgentPoolResourceCollection", + "BuildServiceAgentPoolSizeProperties", + "BuildServiceCollection", + "BuildServiceProperties", + "BuildServicePropertiesResourceRequests", + "BuildStageProperties", + "BuilderProperties", + "BuilderResource", + "BuilderResourceCollection", + "BuildpackBindingLaunchProperties", + "BuildpackBindingProperties", + "BuildpackBindingResource", + "BuildpackBindingResourceCollection", + "BuildpackProperties", + "BuildpacksGroupProperties", + "CertificateProperties", + "CertificateResource", + "CertificateResourceCollection", + "CloudErrorBody", + "ClusterResourceProperties", + "ConfigServerGitProperty", + "ConfigServerProperties", + "ConfigServerResource", + "ConfigServerSettings", + "ConfigServerSettingsErrorRecord", + "ConfigServerSettingsValidateResult", + "ConfigurationServiceGitProperty", + "ConfigurationServiceGitPropertyValidateResult", + "ConfigurationServiceGitRepository", + "ConfigurationServiceInstance", + "ConfigurationServiceProperties", + "ConfigurationServiceResource", + "ConfigurationServiceResourceCollection", + "ConfigurationServiceResourceRequests", + "ConfigurationServiceSettings", + "ConfigurationServiceSettingsValidateResult", + "ContentCertificateProperties", + "CustomDomainProperties", + "CustomDomainResource", + "CustomDomainResourceCollection", + "CustomDomainValidatePayload", + "CustomDomainValidateResult", + "DeploymentInstance", + "DeploymentResource", + "DeploymentResourceCollection", + "DeploymentResourceProperties", + "DeploymentSettings", + "DiagnosticParameters", + "Error", + "GitPatternRepository", + "JarUploadedUserSourceInfo", + "KeyVaultCertificateProperties", + "LoadedCertificate", + "LogFileUrlResponse", + "LogSpecification", + "ManagedIdentityProperties", + "MetricDimension", + "MetricSpecification", + "MonitoringSettingProperties", + "MonitoringSettingResource", + "NameAvailability", + "NameAvailabilityParameters", + "NetCoreZipUploadedUserSourceInfo", + "NetworkProfile", + "NetworkProfileOutboundIPs", + "OperationDetail", + "OperationDisplay", + "OperationProperties", + "PersistentDisk", + "ProxyResource", + "RegenerateTestKeyRequestPayload", + "RequiredTraffic", + "Resource", + "ResourceRequests", + "ResourceSku", + "ResourceSkuCapabilities", + "ResourceSkuCollection", + "ResourceSkuLocationInfo", + "ResourceSkuRestrictionInfo", + "ResourceSkuRestrictions", + "ResourceSkuZoneDetails", + "ResourceUploadDefinition", + "ServiceRegistryInstance", + "ServiceRegistryProperties", + "ServiceRegistryResource", + "ServiceRegistryResourceCollection", + "ServiceRegistryResourceRequests", + "ServiceResource", + "ServiceResourceList", + "ServiceSpecification", + "Sku", + "SkuCapacity", + "SourceUploadedUserSourceInfo", + "StackProperties", + "SupportedBuildpackResource", + "SupportedBuildpackResourceProperties", + "SupportedBuildpacksCollection", + "SupportedRuntimeVersion", + "SupportedStackResource", + "SupportedStackResourceProperties", + "SupportedStacksCollection", + "SystemData", + "TemporaryDisk", + "TestKeys", + "TrackedResource", + "TriggeredBuildResult", + "UploadedUserSourceInfo", + "UserSourceInfo", + "ValidationMessages", + "ActionType", + "AppResourceProvisioningState", + "BindingType", + "BuildProvisioningState", + "BuildResultProvisioningState", + "BuildServiceProvisioningState", + "BuilderProvisioningState", + "BuildpackBindingProvisioningState", + "ConfigServerState", + "ConfigurationServiceProvisioningState", + "CreatedByType", + "DeploymentResourceProvisioningState", + "DeploymentResourceStatus", + "KPackBuildStageProvisioningState", + "LastModifiedByType", + "ManagedIdentityType", + "MonitoringSettingState", + "ProvisioningState", + "ResourceSkuRestrictionsReasonCode", + "ResourceSkuRestrictionsType", + "ServiceRegistryProvisioningState", + "SkuScaleType", + "SupportedRuntimePlatform", + "SupportedRuntimeValue", + "TestKeyType", + "TrafficDirection", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/_app_platform_management_client_enums.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/_app_platform_management_client_enums.py index ac9fe9b1e938..f83baae3f067 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/_app_platform_management_client_enums.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/_app_platform_management_client_enums.py @@ -7,19 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - """ +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" INTERNAL = "Internal" -class AppResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the App - """ + +class AppResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the App.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -27,9 +25,9 @@ class AppResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, UPDATING = "Updating" DELETING = "Deleting" -class BindingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Buildpack Binding Type - """ + +class BindingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Buildpack Binding Type.""" APPLICATION_INSIGHTS = "ApplicationInsights" APACHE_SKY_WALKING = "ApacheSkyWalking" @@ -38,9 +36,9 @@ class BindingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NEW_RELIC = "NewRelic" ELASTIC_APM = "ElasticAPM" -class BuilderProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Builder provision status. - """ + +class BuilderProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Builder provision status.""" CREATING = "Creating" UPDATING = "Updating" @@ -48,9 +46,9 @@ class BuilderProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" DELETING = "Deleting" -class BuildpackBindingProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Buildpack Binding. - """ + +class BuildpackBindingProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Buildpack Binding.""" CREATING = "Creating" UPDATING = "Updating" @@ -58,9 +56,9 @@ class BuildpackBindingProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, FAILED = "Failed" DELETING = "Deleting" -class BuildProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the KPack build result - """ + +class BuildProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" CREATING = "Creating" UPDATING = "Updating" @@ -68,9 +66,9 @@ class BuildProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) FAILED = "Failed" DELETING = "Deleting" -class BuildResultProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the KPack build result - """ + +class BuildResultProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" QUEUING = "Queuing" BUILDING = "Building" @@ -78,9 +76,9 @@ class BuildResultProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, FAILED = "Failed" DELETING = "Deleting" -class BuildServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the KPack build result - """ + +class BuildServiceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" CREATING = "Creating" UPDATING = "Updating" @@ -88,9 +86,9 @@ class BuildServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, FAILED = "Failed" DELETING = "Deleting" -class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the config server. - """ + +class ConfigServerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the config server.""" NOT_AVAILABLE = "NotAvailable" DELETED = "Deleted" @@ -98,9 +96,9 @@ class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ConfigurationServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Application Configuration Service. - """ + +class ConfigurationServiceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Application Configuration Service.""" CREATING = "Creating" UPDATING = "Updating" @@ -108,70 +106,70 @@ class ConfigurationServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMe FAILED = "Failed" DELETING = "Deleting" -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 DeploymentResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Deployment - """ + +class DeploymentResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Deployment.""" CREATING = "Creating" UPDATING = "Updating" SUCCEEDED = "Succeeded" FAILED = "Failed" -class DeploymentResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of the Deployment - """ + +class DeploymentResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the Deployment.""" STOPPED = "Stopped" RUNNING = "Running" -class KPackBuildStageProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of this build stage resource. - """ + +class KPackBuildStageProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of this build stage resource.""" NOT_STARTED = "NotStarted" RUNNING = "Running" SUCCEEDED = "Succeeded" FAILED = "Failed" -class LastModifiedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that last modified the resource. - """ + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class ManagedIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the managed identity - """ + +class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the managed identity.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class MonitoringSettingState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Monitoring Setting. - """ + +class MonitoringSettingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Monitoring Setting.""" NOT_AVAILABLE = "NotAvailable" FAILED = "Failed" SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Service - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Service.""" CREATING = "Creating" UPDATING = "Updating" @@ -185,24 +183,25 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MOVED = "Moved" MOVE_FAILED = "MoveFailed" -class ResourceSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription' + 'NotAvailableForSubscription'. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ResourceSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets the type of restrictions. Possible values include: 'Location', 'Zone' - """ + +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the type of restrictions. Possible values include: 'Location', 'Zone'.""" LOCATION = "Location" ZONE = "Zone" -class ServiceRegistryProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Service Registry. - """ + +class ServiceRegistryProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Service Registry.""" CREATING = "Creating" UPDATING = "Updating" @@ -210,40 +209,40 @@ class ServiceRegistryProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, s FAILED = "Failed" DELETING = "Deleting" -class SkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets or sets the type of the scale. - """ + +class SkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type of the scale.""" NONE = "None" MANUAL = "Manual" AUTOMATIC = "Automatic" -class SupportedRuntimePlatform(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The platform of this runtime version (possible values: "Java" or ".NET"). - """ + +class SupportedRuntimePlatform(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The platform of this runtime version (possible values: "Java" or ".NET").""" JAVA = "Java" _NET_CORE = ".NET Core" -class SupportedRuntimeValue(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The raw value which could be passed to deployment CRUD operations. - """ + +class SupportedRuntimeValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The raw value which could be passed to deployment CRUD operations.""" JAVA8 = "Java_8" JAVA11 = "Java_11" JAVA17 = "Java_17" NET_CORE31 = "NetCore_31" -class TestKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the test key - """ + +class TestKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the test key.""" PRIMARY = "Primary" SECONDARY = "Secondary" -class TrafficDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The direction of required traffic - """ + +class TrafficDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The direction of required traffic.""" INBOUND = "Inbound" OUTBOUND = "Outbound" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/_models_py3.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/_models_py3.py index 44ea53e77086..9d341b95130e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/_models_py3.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,14 +8,23 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._app_platform_management_client_enums import * +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ActiveDeploymentCollection(msrest.serialization.Model): + +class ActiveDeploymentCollection(_serialization.Model): """Object that includes an array of Deployment resource name and set them as active. :ivar active_deployment_names: Collection of Deployment name. @@ -22,24 +32,19 @@ class ActiveDeploymentCollection(msrest.serialization.Model): """ _attribute_map = { - 'active_deployment_names': {'key': 'activeDeploymentNames', 'type': '[str]'}, + "active_deployment_names": {"key": "activeDeploymentNames", "type": "[str]"}, } - def __init__( - self, - *, - active_deployment_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, active_deployment_names: Optional[List[str]] = None, **kwargs): """ :keyword active_deployment_names: Collection of Deployment name. :paramtype active_deployment_names: list[str] """ - super(ActiveDeploymentCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.active_deployment_names = active_deployment_names -class ApplicationInsightsAgentVersions(msrest.serialization.Model): +class ApplicationInsightsAgentVersions(_serialization.Model): """Application Insights agent versions properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -49,24 +54,20 @@ class ApplicationInsightsAgentVersions(msrest.serialization.Model): """ _validation = { - 'java': {'readonly': True}, + "java": {"readonly": True}, } _attribute_map = { - 'java': {'key': 'java', 'type': 'str'}, + "java": {"key": "java", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApplicationInsightsAgentVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.java = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The core properties of ARM resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -82,26 +83,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 @@ -124,26 +121,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 AppResource(ProxyResource): @@ -168,27 +161,27 @@ class AppResource(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': 'AppResourceProperties'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentityProperties'}, - 'location': {'key': 'location', 'type': 'str'}, + "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": "AppResourceProperties"}, + "identity": {"key": "identity", "type": "ManagedIdentityProperties"}, + "location": {"key": "location", "type": "str"}, } def __init__( self, *, - properties: Optional["AppResourceProperties"] = None, - identity: Optional["ManagedIdentityProperties"] = None, + properties: Optional["_models.AppResourceProperties"] = None, + identity: Optional["_models.ManagedIdentityProperties"] = None, location: Optional[str] = None, **kwargs ): @@ -201,13 +194,13 @@ def __init__( resource. :paramtype location: str """ - super(AppResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.identity = identity self.location = location -class AppResourceCollection(msrest.serialization.Model): +class AppResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of App resources. @@ -218,16 +211,12 @@ class AppResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AppResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AppResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["AppResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.AppResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of App resources. @@ -236,12 +225,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(AppResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class AppResourceProperties(msrest.serialization.Model): +class AppResourceProperties(_serialization.Model): """App resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -251,9 +240,9 @@ class AppResourceProperties(msrest.serialization.Model): :ivar url: URL of the App. :vartype url: str :ivar addon_configs: Collection of addons. - :vartype addon_configs: dict[str, dict[str, any]] - :ivar provisioning_state: Provisioning state of the App. Possible values include: "Succeeded", - "Failed", "Creating", "Updating", "Deleting". + :vartype addon_configs: dict[str, dict[str, JSON]] + :ivar provisioning_state: Provisioning state of the App. Known values are: "Succeeded", + "Failed", "Creating", "Updating", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_04_01.models.AppResourceProvisioningState :ivar fqdn: Fully qualified dns Name. @@ -272,41 +261,41 @@ class AppResourceProperties(msrest.serialization.Model): """ _validation = { - 'url': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "url": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'public': {'key': 'public', 'type': 'bool'}, - 'url': {'key': 'url', 'type': 'str'}, - 'addon_configs': {'key': 'addonConfigs', 'type': '{{object}}'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'fqdn': {'key': 'fqdn', 'type': 'str'}, - 'https_only': {'key': 'httpsOnly', 'type': 'bool'}, - 'temporary_disk': {'key': 'temporaryDisk', 'type': 'TemporaryDisk'}, - 'persistent_disk': {'key': 'persistentDisk', 'type': 'PersistentDisk'}, - 'enable_end_to_end_tls': {'key': 'enableEndToEndTLS', 'type': 'bool'}, - 'loaded_certificates': {'key': 'loadedCertificates', 'type': '[LoadedCertificate]'}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "addon_configs": {"key": "addonConfigs", "type": "{{object}}"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "fqdn": {"key": "fqdn", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "temporary_disk": {"key": "temporaryDisk", "type": "TemporaryDisk"}, + "persistent_disk": {"key": "persistentDisk", "type": "PersistentDisk"}, + "enable_end_to_end_tls": {"key": "enableEndToEndTLS", "type": "bool"}, + "loaded_certificates": {"key": "loadedCertificates", "type": "[LoadedCertificate]"}, } def __init__( self, *, public: Optional[bool] = None, - addon_configs: Optional[Dict[str, Dict[str, Any]]] = None, + addon_configs: Optional[Dict[str, Dict[str, JSON]]] = None, fqdn: Optional[str] = None, - https_only: Optional[bool] = False, - temporary_disk: Optional["TemporaryDisk"] = None, - persistent_disk: Optional["PersistentDisk"] = None, - enable_end_to_end_tls: Optional[bool] = False, - loaded_certificates: Optional[List["LoadedCertificate"]] = None, + https_only: bool = False, + temporary_disk: Optional["_models.TemporaryDisk"] = None, + persistent_disk: Optional["_models.PersistentDisk"] = None, + enable_end_to_end_tls: bool = False, + loaded_certificates: Optional[List["_models.LoadedCertificate"]] = None, **kwargs ): """ :keyword public: Indicates whether the App exposes public endpoint. :paramtype public: bool :keyword addon_configs: Collection of addons. - :paramtype addon_configs: dict[str, dict[str, any]] + :paramtype addon_configs: dict[str, dict[str, JSON]] :keyword fqdn: Fully qualified dns Name. :paramtype fqdn: str :keyword https_only: Indicate if only https is allowed. @@ -321,7 +310,7 @@ def __init__( :paramtype loaded_certificates: list[~azure.mgmt.appplatform.v2022_04_01.models.LoadedCertificate] """ - super(AppResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.public = public self.url = None self.addon_configs = addon_configs @@ -334,7 +323,7 @@ def __init__( self.loaded_certificates = loaded_certificates -class AvailableOperations(msrest.serialization.Model): +class AvailableOperations(_serialization.Model): """Available operations of the service. :ivar value: Collection of available operation details. @@ -345,16 +334,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. @@ -363,12 +348,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 AvailableRuntimeVersions(msrest.serialization.Model): +class AvailableRuntimeVersions(_serialization.Model): """AvailableRuntimeVersions. Variables are only populated by the server, and will be ignored when sending a request. @@ -378,20 +363,16 @@ class AvailableRuntimeVersions(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedRuntimeVersion]'}, + "value": {"key": "value", "type": "[SupportedRuntimeVersion]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AvailableRuntimeVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -413,35 +394,30 @@ class BindingResource(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': 'BindingResourceProperties'}, + "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": "BindingResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["BindingResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BindingResourceProperties"] = None, **kwargs): """ :keyword properties: Properties of the Binding resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResourceProperties """ - super(BindingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BindingResourceCollection(msrest.serialization.Model): +class BindingResourceCollection(_serialization.Model): """Object that includes an array of Binding resources and a possible link for next set. :ivar value: Collection of Binding resources. @@ -452,16 +428,12 @@ class BindingResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BindingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BindingResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BindingResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Binding resources. @@ -470,12 +442,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BindingResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BindingResourceProperties(msrest.serialization.Model): +class BindingResourceProperties(_serialization.Model): """Binding resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -489,7 +461,7 @@ class BindingResourceProperties(msrest.serialization.Model): :ivar key: The key of the bound resource. :vartype key: str :ivar binding_parameters: Binding parameters of the Binding resource. - :vartype binding_parameters: dict[str, any] + :vartype binding_parameters: dict[str, JSON] :ivar generated_properties: The generated Spring Boot property file for this binding. The secret will be deducted. :vartype generated_properties: str @@ -500,22 +472,22 @@ class BindingResourceProperties(msrest.serialization.Model): """ _validation = { - 'resource_name': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'generated_properties': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, + "resource_name": {"readonly": True}, + "resource_type": {"readonly": True}, + "generated_properties": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, } _attribute_map = { - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'binding_parameters': {'key': 'bindingParameters', 'type': '{object}'}, - 'generated_properties': {'key': 'generatedProperties', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'str'}, - 'updated_at': {'key': 'updatedAt', 'type': 'str'}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "binding_parameters": {"key": "bindingParameters", "type": "{object}"}, + "generated_properties": {"key": "generatedProperties", "type": "str"}, + "created_at": {"key": "createdAt", "type": "str"}, + "updated_at": {"key": "updatedAt", "type": "str"}, } def __init__( @@ -523,7 +495,7 @@ def __init__( *, resource_id: Optional[str] = None, key: Optional[str] = None, - binding_parameters: Optional[Dict[str, Any]] = None, + binding_parameters: Optional[Dict[str, JSON]] = None, **kwargs ): """ @@ -532,9 +504,9 @@ def __init__( :keyword key: The key of the bound resource. :paramtype key: str :keyword binding_parameters: Binding parameters of the Binding resource. - :paramtype binding_parameters: dict[str, any] + :paramtype binding_parameters: dict[str, JSON] """ - super(BindingResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_name = None self.resource_type = None self.resource_id = resource_id @@ -563,35 +535,30 @@ class Build(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': 'BuildProperties'}, + "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": "BuildProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildProperties"] = None, **kwargs): """ :keyword properties: Properties of the build resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.BuildProperties """ - super(Build, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildCollection(msrest.serialization.Model): +class BuildCollection(_serialization.Model): """Object that includes an array of Build resources and a possible link for next set. :ivar value: Collection of Build resources. @@ -602,17 +569,11 @@ class BuildCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Build]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Build]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Build"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Build"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Collection of Build resources. :paramtype value: list[~azure.mgmt.appplatform.v2022_04_01.models.Build] @@ -620,18 +581,18 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuilderProperties(msrest.serialization.Model): +class BuilderProperties(_serialization.Model): """KPack Builder properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Builder provision status. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Builder provision status. Known values are: "Creating", "Updating", + "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_04_01.models.BuilderProvisioningState :ivar stack: Builder cluster stack property. @@ -642,20 +603,20 @@ class BuilderProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'stack': {'key': 'stack', 'type': 'StackProperties'}, - 'buildpack_groups': {'key': 'buildpackGroups', 'type': '[BuildpacksGroupProperties]'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "stack": {"key": "stack", "type": "StackProperties"}, + "buildpack_groups": {"key": "buildpackGroups", "type": "[BuildpacksGroupProperties]"}, } def __init__( self, *, - stack: Optional["StackProperties"] = None, - buildpack_groups: Optional[List["BuildpacksGroupProperties"]] = None, + stack: Optional["_models.StackProperties"] = None, + buildpack_groups: Optional[List["_models.BuildpacksGroupProperties"]] = None, **kwargs ): """ @@ -665,7 +626,7 @@ def __init__( :paramtype buildpack_groups: list[~azure.mgmt.appplatform.v2022_04_01.models.BuildpacksGroupProperties] """ - super(BuilderProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.stack = stack self.buildpack_groups = buildpack_groups @@ -689,35 +650,30 @@ class BuilderResource(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': 'BuilderProperties'}, + "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": "BuilderProperties"}, } - def __init__( - self, - *, - properties: Optional["BuilderProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuilderProperties"] = None, **kwargs): """ :keyword properties: Property of the Builder resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.BuilderProperties """ - super(BuilderResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuilderResourceCollection(msrest.serialization.Model): +class BuilderResourceCollection(_serialization.Model): """Object that includes an array of Builder resources and a possible link for next set. :ivar value: Collection of Builder resources. @@ -728,16 +684,12 @@ class BuilderResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuilderResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuilderResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BuilderResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BuilderResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Builder resources. @@ -746,12 +698,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuilderResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildpackBindingLaunchProperties(msrest.serialization.Model): +class BuildpackBindingLaunchProperties(_serialization.Model): """Buildpack Binding Launch Properties. :ivar properties: Non-sensitive properties for launchProperties. @@ -761,16 +713,12 @@ class BuildpackBindingLaunchProperties(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'secrets': {'key': 'secrets', 'type': '{str}'}, + "properties": {"key": "properties", "type": "{str}"}, + "secrets": {"key": "secrets", "type": "{str}"}, } def __init__( - self, - *, - properties: Optional[Dict[str, str]] = None, - secrets: Optional[Dict[str, str]] = None, - **kwargs + self, *, properties: Optional[Dict[str, str]] = None, secrets: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword properties: Non-sensitive properties for launchProperties. @@ -778,21 +726,21 @@ def __init__( :keyword secrets: Sensitive properties for launchProperties. :paramtype secrets: dict[str, str] """ - super(BuildpackBindingLaunchProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.secrets = secrets -class BuildpackBindingProperties(msrest.serialization.Model): +class BuildpackBindingProperties(_serialization.Model): """Properties of a buildpack binding. Variables are only populated by the server, and will be ignored when sending a request. - :ivar binding_type: Buildpack Binding Type. Possible values include: "ApplicationInsights", - "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", "ElasticAPM". + :ivar binding_type: Buildpack Binding Type. Known values are: "ApplicationInsights", + "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", and "ElasticAPM". :vartype binding_type: str or ~azure.mgmt.appplatform.v2022_04_01.models.BindingType - :ivar provisioning_state: State of the Buildpack Binding. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Buildpack Binding. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingProvisioningState :ivar launch_properties: The object describes the buildpack binding launch properties. @@ -801,31 +749,31 @@ class BuildpackBindingProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'binding_type': {'key': 'bindingType', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'launch_properties': {'key': 'launchProperties', 'type': 'BuildpackBindingLaunchProperties'}, + "binding_type": {"key": "bindingType", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "launch_properties": {"key": "launchProperties", "type": "BuildpackBindingLaunchProperties"}, } def __init__( self, *, - binding_type: Optional[Union[str, "BindingType"]] = None, - launch_properties: Optional["BuildpackBindingLaunchProperties"] = None, + binding_type: Optional[Union[str, "_models.BindingType"]] = None, + launch_properties: Optional["_models.BuildpackBindingLaunchProperties"] = None, **kwargs ): """ - :keyword binding_type: Buildpack Binding Type. Possible values include: "ApplicationInsights", - "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", "ElasticAPM". + :keyword binding_type: Buildpack Binding Type. Known values are: "ApplicationInsights", + "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", and "ElasticAPM". :paramtype binding_type: str or ~azure.mgmt.appplatform.v2022_04_01.models.BindingType :keyword launch_properties: The object describes the buildpack binding launch properties. :paramtype launch_properties: ~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingLaunchProperties """ - super(BuildpackBindingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.binding_type = binding_type self.provisioning_state = None self.launch_properties = launch_properties @@ -849,35 +797,30 @@ class BuildpackBindingResource(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': 'BuildpackBindingProperties'}, + "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": "BuildpackBindingProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildpackBindingProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildpackBindingProperties"] = None, **kwargs): """ :keyword properties: Properties of a buildpack binding. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingProperties """ - super(BuildpackBindingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildpackBindingResourceCollection(msrest.serialization.Model): +class BuildpackBindingResourceCollection(_serialization.Model): """Object that includes an array of BuildpackBinding resources and a possible link for next set. :ivar value: Collection of BuildpackBinding resources. @@ -888,14 +831,14 @@ class BuildpackBindingResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildpackBindingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildpackBindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["BuildpackBindingResource"]] = None, + value: Optional[List["_models.BuildpackBindingResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -906,12 +849,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildpackBindingResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildpackProperties(msrest.serialization.Model): +class BuildpackProperties(_serialization.Model): """Buildpack properties payload. :ivar id: Id of the buildpack. @@ -919,24 +862,19 @@ class BuildpackProperties(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Id of the buildpack. :paramtype id: str """ - super(BuildpackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class BuildpacksGroupProperties(msrest.serialization.Model): +class BuildpacksGroupProperties(_serialization.Model): """Buildpack group properties of the Builder. :ivar name: Buildpack group name. @@ -946,16 +884,12 @@ class BuildpacksGroupProperties(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'buildpacks': {'key': 'buildpacks', 'type': '[BuildpackProperties]'}, + "name": {"key": "name", "type": "str"}, + "buildpacks": {"key": "buildpacks", "type": "[BuildpackProperties]"}, } def __init__( - self, - *, - name: Optional[str] = None, - buildpacks: Optional[List["BuildpackProperties"]] = None, - **kwargs + self, *, name: Optional[str] = None, buildpacks: Optional[List["_models.BuildpackProperties"]] = None, **kwargs ): """ :keyword name: Buildpack group name. @@ -963,12 +897,12 @@ def __init__( :keyword buildpacks: Buildpacks in the buildpack group. :paramtype buildpacks: list[~azure.mgmt.appplatform.v2022_04_01.models.BuildpackProperties] """ - super(BuildpacksGroupProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.buildpacks = buildpacks -class BuildProperties(msrest.serialization.Model): +class BuildProperties(_serialization.Model): """Build resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -979,8 +913,8 @@ class BuildProperties(msrest.serialization.Model): :vartype builder: str :ivar agent_pool: The resource id of agent pool. :vartype agent_pool: str - :ivar provisioning_state: Provisioning state of the KPack build result. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_04_01.models.BuildProvisioningState :ivar env: The environment variables for this build. @@ -991,17 +925,17 @@ class BuildProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'triggered_build_result': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "triggered_build_result": {"readonly": True}, } _attribute_map = { - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'builder': {'key': 'builder', 'type': 'str'}, - 'agent_pool': {'key': 'agentPool', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'env': {'key': 'env', 'type': '{str}'}, - 'triggered_build_result': {'key': 'triggeredBuildResult', 'type': 'TriggeredBuildResult'}, + "relative_path": {"key": "relativePath", "type": "str"}, + "builder": {"key": "builder", "type": "str"}, + "agent_pool": {"key": "agentPool", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "env": {"key": "env", "type": "{str}"}, + "triggered_build_result": {"key": "triggeredBuildResult", "type": "TriggeredBuildResult"}, } def __init__( @@ -1023,7 +957,7 @@ def __init__( :keyword env: The environment variables for this build. :paramtype env: dict[str, str] """ - super(BuildProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.relative_path = relative_path self.builder = builder self.agent_pool = agent_pool @@ -1050,35 +984,30 @@ class BuildResult(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': 'BuildResultProperties'}, + "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": "BuildResultProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildResultProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildResultProperties"] = None, **kwargs): """ :keyword properties: Properties of the build result resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.BuildResultProperties """ - super(BuildResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildResultCollection(msrest.serialization.Model): +class BuildResultCollection(_serialization.Model): """Object that includes an array of Build result resources and a possible link for next set. :ivar value: Collection of Build result resources. @@ -1089,16 +1018,12 @@ class BuildResultCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildResult]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BuildResult"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BuildResult"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Build result resources. @@ -1107,12 +1032,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildResultCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildResultLog(msrest.serialization.Model): +class BuildResultLog(_serialization.Model): """Build result log resource properties payload. :ivar blob_url: The public download URL of this build result log. @@ -1120,32 +1045,27 @@ class BuildResultLog(msrest.serialization.Model): """ _attribute_map = { - 'blob_url': {'key': 'blobUrl', 'type': 'str'}, + "blob_url": {"key": "blobUrl", "type": "str"}, } - def __init__( - self, - *, - blob_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, blob_url: Optional[str] = None, **kwargs): """ :keyword blob_url: The public download URL of this build result log. :paramtype blob_url: str """ - super(BuildResultLog, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob_url = blob_url -class BuildResultProperties(msrest.serialization.Model): +class BuildResultProperties(_serialization.Model): """Build result resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. :ivar name: The name of this build result. :vartype name: str - :ivar provisioning_state: Provisioning state of the KPack build result. Possible values - include: "Queuing", "Building", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Queuing", "Building", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_04_01.models.BuildResultProvisioningState :ivar build_pod_name: The build pod name which can be used to get the build log streaming. @@ -1156,75 +1076,64 @@ class BuildResultProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'build_stages': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "build_stages": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'build_pod_name': {'key': 'buildPodName', 'type': 'str'}, - 'build_stages': {'key': 'buildStages', 'type': '[BuildStageProperties]'}, + "name": {"key": "name", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "build_pod_name": {"key": "buildPodName", "type": "str"}, + "build_stages": {"key": "buildStages", "type": "[BuildStageProperties]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - build_pod_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, build_pod_name: Optional[str] = None, **kwargs): """ :keyword name: The name of this build result. :paramtype name: str :keyword build_pod_name: The build pod name which can be used to get the build log streaming. :paramtype build_pod_name: str """ - super(BuildResultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.provisioning_state = None self.build_pod_name = build_pod_name self.build_stages = None -class UserSourceInfo(msrest.serialization.Model): +class UserSourceInfo(_serialization.Model): """Source information for a deployment. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: BuildResultUserSourceInfo, UploadedUserSourceInfo. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + BuildResultUserSourceInfo, UploadedUserSourceInfo All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, } _subtype_map = { - 'type': {'BuildResult': 'BuildResultUserSourceInfo', 'UploadedUserSourceInfo': 'UploadedUserSourceInfo'} + "type": {"BuildResult": "BuildResultUserSourceInfo", "UploadedUserSourceInfo": "UploadedUserSourceInfo"} } - def __init__( - self, - *, - version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, version: Optional[str] = None, **kwargs): """ :keyword version: Version of the source. :paramtype version: str """ - super(UserSourceInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None # type: Optional[str] self.version = version @@ -1234,7 +1143,7 @@ class BuildResultUserSourceInfo(UserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -1244,22 +1153,16 @@ class BuildResultUserSourceInfo(UserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'build_result_id': {'key': 'buildResultId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "build_result_id": {"key": "buildResultId", "type": "str"}, } - def __init__( - self, - *, - version: Optional[str] = None, - build_result_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, version: Optional[str] = None, build_result_id: Optional[str] = None, **kwargs): """ :keyword version: Version of the source. :paramtype version: str @@ -1267,8 +1170,8 @@ def __init__( Spring instance. :paramtype build_result_id: str """ - super(BuildResultUserSourceInfo, self).__init__(version=version, **kwargs) - self.type = 'BuildResult' # type: str + super().__init__(version=version, **kwargs) + self.type = "BuildResult" # type: str self.build_result_id = build_result_id @@ -1290,35 +1193,30 @@ class BuildService(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': 'BuildServiceProperties'}, + "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": "BuildServiceProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildServiceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildServiceProperties"] = None, **kwargs): """ :keyword properties: Properties of the build resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceProperties """ - super(BuildService, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildServiceAgentPoolProperties(msrest.serialization.Model): +class BuildServiceAgentPoolProperties(_serialization.Model): """Build service agent pool properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1331,26 +1229,21 @@ class BuildServiceAgentPoolProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'pool_size': {'key': 'poolSize', 'type': 'BuildServiceAgentPoolSizeProperties'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "pool_size": {"key": "poolSize", "type": "BuildServiceAgentPoolSizeProperties"}, } - def __init__( - self, - *, - pool_size: Optional["BuildServiceAgentPoolSizeProperties"] = None, - **kwargs - ): + def __init__(self, *, pool_size: Optional["_models.BuildServiceAgentPoolSizeProperties"] = None, **kwargs): """ :keyword pool_size: build service agent pool size properties. :paramtype pool_size: ~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolSizeProperties """ - super(BuildServiceAgentPoolProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.pool_size = pool_size @@ -1373,36 +1266,31 @@ class BuildServiceAgentPoolResource(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': 'BuildServiceAgentPoolProperties'}, + "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": "BuildServiceAgentPoolProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildServiceAgentPoolProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildServiceAgentPoolProperties"] = None, **kwargs): """ :keyword properties: build service agent pool properties. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolProperties """ - super(BuildServiceAgentPoolResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildServiceAgentPoolResourceCollection(msrest.serialization.Model): +class BuildServiceAgentPoolResourceCollection(_serialization.Model): """Object that includes an array of build service agent pool resources and a possible link for next set. :ivar value: Collection of build service agent pool resource. @@ -1413,14 +1301,14 @@ class BuildServiceAgentPoolResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildServiceAgentPoolResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildServiceAgentPoolResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["BuildServiceAgentPoolResource"]] = None, + value: Optional[List["_models.BuildServiceAgentPoolResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1432,12 +1320,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildServiceAgentPoolResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildServiceAgentPoolSizeProperties(msrest.serialization.Model): +class BuildServiceAgentPoolSizeProperties(_serialization.Model): """Build service agent pool size properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1451,33 +1339,28 @@ class BuildServiceAgentPoolSizeProperties(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The name of build service agent pool size. :paramtype name: str """ - super(BuildServiceAgentPoolSizeProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.cpu = None self.memory = None -class BuildServiceCollection(msrest.serialization.Model): +class BuildServiceCollection(_serialization.Model): """Object that includes an array of Build service resources and a possible link for next set. :ivar value: Collection of Build service resources. @@ -1488,16 +1371,12 @@ class BuildServiceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildService]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildService]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BuildService"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BuildService"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Build service resources. @@ -1506,20 +1385,20 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildServiceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildServiceProperties(msrest.serialization.Model): +class BuildServiceProperties(_serialization.Model): """Build service resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. :ivar k_pack_version: The installed KPack version in this build service. :vartype k_pack_version: str - :ivar provisioning_state: Provisioning state of the KPack build result. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceProvisioningState :ivar resource_requests: The runtime resource configuration of this build service. @@ -1528,20 +1407,20 @@ class BuildServiceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'k_pack_version': {'key': 'kPackVersion', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'BuildServicePropertiesResourceRequests'}, + "k_pack_version": {"key": "kPackVersion", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "BuildServicePropertiesResourceRequests"}, } def __init__( self, *, k_pack_version: Optional[str] = None, - resource_requests: Optional["BuildServicePropertiesResourceRequests"] = None, + resource_requests: Optional["_models.BuildServicePropertiesResourceRequests"] = None, **kwargs ): """ @@ -1551,13 +1430,13 @@ def __init__( :paramtype resource_requests: ~azure.mgmt.appplatform.v2022_04_01.models.BuildServicePropertiesResourceRequests """ - super(BuildServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.k_pack_version = k_pack_version self.provisioning_state = None self.resource_requests = resource_requests -class BuildServicePropertiesResourceRequests(msrest.serialization.Model): +class BuildServicePropertiesResourceRequests(_serialization.Model): """The runtime resource configuration of this build service. Variables are only populated by the server, and will be ignored when sending a request. @@ -1569,71 +1448,63 @@ class BuildServicePropertiesResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BuildServicePropertiesResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None -class BuildStageProperties(msrest.serialization.Model): +class BuildStageProperties(_serialization.Model): """The build stage (init-container and container) resources in build pod. Variables are only populated by the server, and will be ignored when sending a request. :ivar name: The name of this build stage resource. :vartype name: str - :ivar status: The provisioning state of this build stage resource. Possible values include: - "NotStarted", "Running", "Succeeded", "Failed". + :ivar status: The provisioning state of this build stage resource. Known values are: + "NotStarted", "Running", "Succeeded", and "Failed". :vartype status: str or ~azure.mgmt.appplatform.v2022_04_01.models.KPackBuildStageProvisioningState """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BuildStageProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """Certificate resource payload. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ContentCertificateProperties, KeyVaultCertificateProperties. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContentCertificateProperties, KeyVaultCertificateProperties Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -1652,38 +1523,37 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, } _subtype_map = { - 'type': {'ContentCertificate': 'ContentCertificateProperties', 'KeyVaultCertificate': 'KeyVaultCertificateProperties'} + "type": { + "ContentCertificate": "ContentCertificateProperties", + "KeyVaultCertificate": "KeyVaultCertificateProperties", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificateProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None # type: Optional[str] self.thumbprint = None self.issuer = None @@ -1712,35 +1582,30 @@ class CertificateResource(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': 'CertificateProperties'}, + "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": "CertificateProperties"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: Properties of the certificate resource payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.CertificateProperties """ - super(CertificateResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CertificateResourceCollection(msrest.serialization.Model): +class CertificateResourceCollection(_serialization.Model): """Collection compose of certificate resources list and a possible link for next page. :ivar value: The certificate resources list. @@ -1750,16 +1615,12 @@ class CertificateResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CertificateResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CertificateResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CertificateResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The certificate resources list. @@ -1767,12 +1628,12 @@ def __init__( :keyword next_link: The link to next page of certificate list. :paramtype next_link: str """ - super(CertificateResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -1789,10 +1650,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -1801,7 +1662,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -1817,21 +1678,21 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.appplatform.v2022_04_01.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class ClusterResourceProperties(msrest.serialization.Model): +class ClusterResourceProperties(_serialization.Model): """Service properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Provisioning state of the Service. Possible values include: - "Creating", "Updating", "Starting", "Stopping", "Deleting", "Deleted", "Succeeded", "Failed", - "Moving", "Moved", "MoveFailed". + :ivar provisioning_state: Provisioning state of the Service. Known values are: "Creating", + "Updating", "Starting", "Stopping", "Deleting", "Deleted", "Succeeded", "Failed", "Moving", + "Moved", and "MoveFailed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_04_01.models.ProvisioningState :ivar network_profile: Network profile of the Service. @@ -1847,27 +1708,23 @@ class ClusterResourceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'version': {'readonly': True}, - 'service_id': {'readonly': True}, - 'fqdn': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "service_id": {"readonly": True}, + "fqdn": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'network_profile': {'key': 'networkProfile', 'type': 'NetworkProfile'}, - 'version': {'key': 'version', 'type': 'int'}, - 'service_id': {'key': 'serviceId', 'type': 'str'}, - 'zone_redundant': {'key': 'zoneRedundant', 'type': 'bool'}, - 'fqdn': {'key': 'fqdn', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "network_profile": {"key": "networkProfile", "type": "NetworkProfile"}, + "version": {"key": "version", "type": "int"}, + "service_id": {"key": "serviceId", "type": "str"}, + "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, + "fqdn": {"key": "fqdn", "type": "str"}, } def __init__( - self, - *, - network_profile: Optional["NetworkProfile"] = None, - zone_redundant: Optional[bool] = False, - **kwargs + self, *, network_profile: Optional["_models.NetworkProfile"] = None, zone_redundant: bool = False, **kwargs ): """ :keyword network_profile: Network profile of the Service. @@ -1875,7 +1732,7 @@ def __init__( :keyword zone_redundant: :paramtype zone_redundant: bool """ - super(ClusterResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.network_profile = network_profile self.version = None @@ -1884,14 +1741,14 @@ def __init__( self.fqdn = None -class ConfigServerGitProperty(msrest.serialization.Model): +class ConfigServerGitProperty(_serialization.Model): """Property of git. All required parameters must be populated in order to send to Azure. :ivar repositories: Repositories of git. :vartype repositories: list[~azure.mgmt.appplatform.v2022_04_01.models.GitPatternRepository] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -1912,27 +1769,27 @@ class ConfigServerGitProperty(msrest.serialization.Model): """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'repositories': {'key': 'repositories', 'type': '[GitPatternRepository]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "repositories": {"key": "repositories", "type": "[GitPatternRepository]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( self, *, uri: str, - repositories: Optional[List["GitPatternRepository"]] = None, + repositories: Optional[List["_models.GitPatternRepository"]] = None, label: Optional[str] = None, search_paths: Optional[List[str]] = None, username: Optional[str] = None, @@ -1946,7 +1803,7 @@ def __init__( """ :keyword repositories: Repositories of git. :paramtype repositories: list[~azure.mgmt.appplatform.v2022_04_01.models.GitPatternRepository] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -1965,7 +1822,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(ConfigServerGitProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.repositories = repositories self.uri = uri self.label = label @@ -1978,13 +1835,13 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ConfigServerProperties(msrest.serialization.Model): +class ConfigServerProperties(_serialization.Model): """Config server git properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the config server. Possible values include: "NotAvailable", - "Deleted", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the config server. Known values are: "NotAvailable", + "Deleted", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerState :ivar error: Error when apply config server settings. @@ -1994,20 +1851,20 @@ class ConfigServerProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'config_server': {'key': 'configServer', 'type': 'ConfigServerSettings'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "config_server": {"key": "configServer", "type": "ConfigServerSettings"}, } def __init__( self, *, - error: Optional["Error"] = None, - config_server: Optional["ConfigServerSettings"] = None, + error: Optional["_models.Error"] = None, + config_server: Optional["_models.ConfigServerSettings"] = None, **kwargs ): """ @@ -2016,7 +1873,7 @@ def __init__( :keyword config_server: Settings of config server. :paramtype config_server: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerSettings """ - super(ConfigServerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.config_server = config_server @@ -2040,35 +1897,30 @@ class ConfigServerResource(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': 'ConfigServerProperties'}, + "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": "ConfigServerProperties"}, } - def __init__( - self, - *, - properties: Optional["ConfigServerProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ConfigServerProperties"] = None, **kwargs): """ :keyword properties: Properties of the Config Server resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerProperties """ - super(ConfigServerResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ConfigServerSettings(msrest.serialization.Model): +class ConfigServerSettings(_serialization.Model): """The settings of config server. :ivar git_property: Property of git environment. @@ -2076,24 +1928,19 @@ class ConfigServerSettings(msrest.serialization.Model): """ _attribute_map = { - 'git_property': {'key': 'gitProperty', 'type': 'ConfigServerGitProperty'}, + "git_property": {"key": "gitProperty", "type": "ConfigServerGitProperty"}, } - def __init__( - self, - *, - git_property: Optional["ConfigServerGitProperty"] = None, - **kwargs - ): + def __init__(self, *, git_property: Optional["_models.ConfigServerGitProperty"] = None, **kwargs): """ :keyword git_property: Property of git environment. :paramtype git_property: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerGitProperty """ - super(ConfigServerSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property = git_property -class ConfigServerSettingsErrorRecord(msrest.serialization.Model): +class ConfigServerSettingsErrorRecord(_serialization.Model): """Error record of the config server settings. :ivar name: The name of the config server settings error record. @@ -2105,18 +1952,13 @@ class ConfigServerSettingsErrorRecord(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'messages': {'key': 'messages', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, } def __init__( - self, - *, - name: Optional[str] = None, - uri: Optional[str] = None, - messages: Optional[List[str]] = None, - **kwargs + self, *, name: Optional[str] = None, uri: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs ): """ :keyword name: The name of the config server settings error record. @@ -2126,13 +1968,13 @@ def __init__( :keyword messages: The detail error messages of the record. :paramtype messages: list[str] """ - super(ConfigServerSettingsErrorRecord, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.uri = uri self.messages = messages -class ConfigServerSettingsValidateResult(msrest.serialization.Model): +class ConfigServerSettingsValidateResult(_serialization.Model): """Validation result for config server settings. :ivar is_valid: Indicate if the config server settings are valid. @@ -2143,15 +1985,15 @@ class ConfigServerSettingsValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'details': {'key': 'details', 'type': '[ConfigServerSettingsErrorRecord]'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "details": {"key": "details", "type": "[ConfigServerSettingsErrorRecord]"}, } def __init__( self, *, is_valid: Optional[bool] = None, - details: Optional[List["ConfigServerSettingsErrorRecord"]] = None, + details: Optional[List["_models.ConfigServerSettingsErrorRecord"]] = None, **kwargs ): """ @@ -2161,12 +2003,12 @@ def __init__( :paramtype details: list[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerSettingsErrorRecord] """ - super(ConfigServerSettingsValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.details = details -class ConfigurationServiceGitProperty(msrest.serialization.Model): +class ConfigurationServiceGitProperty(_serialization.Model): """Property of git environment. :ivar repositories: Repositories of Application Configuration Service git property. @@ -2175,25 +2017,20 @@ class ConfigurationServiceGitProperty(msrest.serialization.Model): """ _attribute_map = { - 'repositories': {'key': 'repositories', 'type': '[ConfigurationServiceGitRepository]'}, + "repositories": {"key": "repositories", "type": "[ConfigurationServiceGitRepository]"}, } - def __init__( - self, - *, - repositories: Optional[List["ConfigurationServiceGitRepository"]] = None, - **kwargs - ): + def __init__(self, *, repositories: Optional[List["_models.ConfigurationServiceGitRepository"]] = None, **kwargs): """ :keyword repositories: Repositories of Application Configuration Service git property. :paramtype repositories: list[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceGitRepository] """ - super(ConfigurationServiceGitProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.repositories = repositories -class ConfigurationServiceGitPropertyValidateResult(msrest.serialization.Model): +class ConfigurationServiceGitPropertyValidateResult(_serialization.Model): """Validation result for configuration service settings. :ivar is_valid: Indicate if the configuration service settings are valid. @@ -2204,15 +2041,15 @@ class ConfigurationServiceGitPropertyValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'git_repos_validation_result': {'key': 'gitReposValidationResult', 'type': '[ValidationMessages]'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "git_repos_validation_result": {"key": "gitReposValidationResult", "type": "[ValidationMessages]"}, } def __init__( self, *, is_valid: Optional[bool] = None, - git_repos_validation_result: Optional[List["ValidationMessages"]] = None, + git_repos_validation_result: Optional[List["_models.ValidationMessages"]] = None, **kwargs ): """ @@ -2222,23 +2059,23 @@ def __init__( :paramtype git_repos_validation_result: list[~azure.mgmt.appplatform.v2022_04_01.models.ValidationMessages] """ - super(ConfigurationServiceGitPropertyValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.git_repos_validation_result = git_repos_validation_result -class ConfigurationServiceGitRepository(msrest.serialization.Model): +class ConfigurationServiceGitRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes """Git repository property payload for Application Configuration Service. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the repository. + :ivar name: Name of the repository. Required. :vartype name: str - :ivar patterns: Required. Collection of patterns of the repository. + :ivar patterns: Collection of patterns of the repository. Required. :vartype patterns: list[str] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str - :ivar label: Required. Label of the repository. + :ivar label: Label of the repository. Required. :vartype label: str :ivar search_paths: Searching path of the repository. :vartype search_paths: list[str] @@ -2257,24 +2094,24 @@ class ConfigurationServiceGitRepository(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'patterns': {'required': True}, - 'uri': {'required': True}, - 'label': {'required': True}, + "name": {"required": True}, + "patterns": {"required": True}, + "uri": {"required": True}, + "label": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'patterns': {'key': 'patterns', 'type': '[str]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "patterns": {"key": "patterns", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( @@ -2294,13 +2131,13 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of the repository. + :keyword name: Name of the repository. Required. :paramtype name: str - :keyword patterns: Required. Collection of patterns of the repository. + :keyword patterns: Collection of patterns of the repository. Required. :paramtype patterns: list[str] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str - :keyword label: Required. Label of the repository. + :keyword label: Label of the repository. Required. :paramtype label: str :keyword search_paths: Searching path of the repository. :paramtype search_paths: list[str] @@ -2317,7 +2154,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(ConfigurationServiceGitRepository, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.patterns = patterns self.uri = uri @@ -2331,7 +2168,7 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ConfigurationServiceInstance(msrest.serialization.Model): +class ConfigurationServiceInstance(_serialization.Model): """Collection of instances belong to the Application Configuration Service. Variables are only populated by the server, and will be ignored when sending a request. @@ -2343,33 +2180,29 @@ class ConfigurationServiceInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ConfigurationServiceInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class ConfigurationServiceProperties(msrest.serialization.Model): +class ConfigurationServiceProperties(_serialization.Model): """Application Configuration Service properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Application Configuration Service. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Application Configuration Service. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceProvisioningState :ivar resource_requests: The requested resource quantity for required CPU and Memory. @@ -2383,29 +2216,24 @@ class ConfigurationServiceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'resource_requests': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'ConfigurationServiceResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[ConfigurationServiceInstance]'}, - 'settings': {'key': 'settings', 'type': 'ConfigurationServiceSettings'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "ConfigurationServiceResourceRequests"}, + "instances": {"key": "instances", "type": "[ConfigurationServiceInstance]"}, + "settings": {"key": "settings", "type": "ConfigurationServiceSettings"}, } - def __init__( - self, - *, - settings: Optional["ConfigurationServiceSettings"] = None, - **kwargs - ): + def __init__(self, *, settings: Optional["_models.ConfigurationServiceSettings"] = None, **kwargs): """ :keyword settings: The settings of Application Configuration Service. :paramtype settings: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceSettings """ - super(ConfigurationServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.resource_requests = None self.instances = None @@ -2430,36 +2258,31 @@ class ConfigurationServiceResource(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': 'ConfigurationServiceProperties'}, + "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": "ConfigurationServiceProperties"}, } - def __init__( - self, - *, - properties: Optional["ConfigurationServiceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ConfigurationServiceProperties"] = None, **kwargs): """ :keyword properties: Application Configuration Service properties payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceProperties """ - super(ConfigurationServiceResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ConfigurationServiceResourceCollection(msrest.serialization.Model): +class ConfigurationServiceResourceCollection(_serialization.Model): """Object that includes an array of configuration service resources and a possible link for next set. :ivar value: Collection of configuration service resources. @@ -2470,14 +2293,14 @@ class ConfigurationServiceResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ConfigurationServiceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ConfigurationServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ConfigurationServiceResource"]] = None, + value: Optional[List["_models.ConfigurationServiceResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2488,12 +2311,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ConfigurationServiceResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ConfigurationServiceResourceRequests(msrest.serialization.Model): +class ConfigurationServiceResourceRequests(_serialization.Model): """Resource request payload of Application Configuration Service. Variables are only populated by the server, and will be ignored when sending a request. @@ -2507,30 +2330,26 @@ class ConfigurationServiceResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, - 'instance_count': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ConfigurationServiceResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None self.instance_count = None -class ConfigurationServiceSettings(msrest.serialization.Model): +class ConfigurationServiceSettings(_serialization.Model): """The settings of Application Configuration Service. :ivar git_property: Property of git environment. @@ -2539,25 +2358,20 @@ class ConfigurationServiceSettings(msrest.serialization.Model): """ _attribute_map = { - 'git_property': {'key': 'gitProperty', 'type': 'ConfigurationServiceGitProperty'}, + "git_property": {"key": "gitProperty", "type": "ConfigurationServiceGitProperty"}, } - def __init__( - self, - *, - git_property: Optional["ConfigurationServiceGitProperty"] = None, - **kwargs - ): + def __init__(self, *, git_property: Optional["_models.ConfigurationServiceGitProperty"] = None, **kwargs): """ :keyword git_property: Property of git environment. :paramtype git_property: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceGitProperty """ - super(ConfigurationServiceSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property = git_property -class ConfigurationServiceSettingsValidateResult(msrest.serialization.Model): +class ConfigurationServiceSettingsValidateResult(_serialization.Model): """Validation result for configuration service settings. :ivar git_property_validation_result: Validation result for configuration service settings. @@ -2566,13 +2380,16 @@ class ConfigurationServiceSettingsValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'git_property_validation_result': {'key': 'gitPropertyValidationResult', 'type': 'ConfigurationServiceGitPropertyValidateResult'}, + "git_property_validation_result": { + "key": "gitPropertyValidationResult", + "type": "ConfigurationServiceGitPropertyValidateResult", + }, } def __init__( self, *, - git_property_validation_result: Optional["ConfigurationServiceGitPropertyValidateResult"] = None, + git_property_validation_result: Optional["_models.ConfigurationServiceGitPropertyValidateResult"] = None, **kwargs ): """ @@ -2580,7 +2397,7 @@ def __init__( :paramtype git_property_validation_result: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceGitPropertyValidateResult """ - super(ConfigurationServiceSettingsValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property_validation_result = git_property_validation_result @@ -2591,7 +2408,7 @@ class ContentCertificateProperties(CertificateProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -2612,44 +2429,39 @@ class ContentCertificateProperties(CertificateProperties): """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, - 'content': {'key': 'content', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "content": {"key": "content", "type": "str"}, } - def __init__( - self, - *, - content: Optional[str] = None, - **kwargs - ): + def __init__(self, *, content: Optional[str] = None, **kwargs): """ :keyword content: The content of uploaded certificate. :paramtype content: str """ - super(ContentCertificateProperties, self).__init__(**kwargs) - self.type = 'ContentCertificate' # type: str + super().__init__(**kwargs) + self.type = "ContentCertificate" # type: str self.content = content -class CustomDomainProperties(msrest.serialization.Model): +class CustomDomainProperties(_serialization.Model): """Custom domain of app resource payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2663,29 +2475,23 @@ class CustomDomainProperties(msrest.serialization.Model): """ _validation = { - 'app_name': {'readonly': True}, + "app_name": {"readonly": True}, } _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'app_name': {'key': 'appName', 'type': 'str'}, - 'cert_name': {'key': 'certName', 'type': 'str'}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "app_name": {"key": "appName", "type": "str"}, + "cert_name": {"key": "certName", "type": "str"}, } - def __init__( - self, - *, - thumbprint: Optional[str] = None, - cert_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, thumbprint: Optional[str] = None, cert_name: Optional[str] = None, **kwargs): """ :keyword thumbprint: The thumbprint of bound certificate. :paramtype thumbprint: str :keyword cert_name: The bound certificate name of domain. :paramtype cert_name: str """ - super(CustomDomainProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = thumbprint self.app_name = None self.cert_name = cert_name @@ -2709,35 +2515,30 @@ class CustomDomainResource(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': 'CustomDomainProperties'}, + "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": "CustomDomainProperties"}, } - def __init__( - self, - *, - properties: Optional["CustomDomainProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CustomDomainProperties"] = None, **kwargs): """ :keyword properties: Properties of the custom domain resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainProperties """ - super(CustomDomainResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CustomDomainResourceCollection(msrest.serialization.Model): +class CustomDomainResourceCollection(_serialization.Model): """Collection compose of a custom domain resources list and a possible link for next page. :ivar value: The custom domain resources list. @@ -2747,16 +2548,12 @@ class CustomDomainResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CustomDomainResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CustomDomainResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The custom domain resources list. @@ -2764,43 +2561,38 @@ def __init__( :keyword next_link: The link to next page of custom domain list. :paramtype next_link: str """ - super(CustomDomainResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CustomDomainValidatePayload(msrest.serialization.Model): +class CustomDomainValidatePayload(_serialization.Model): """Custom domain validate payload. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name to be validated. + :ivar name: Name to be validated. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Name to be validated. + :keyword name: Name to be validated. Required. :paramtype name: str """ - super(CustomDomainValidatePayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CustomDomainValidateResult(msrest.serialization.Model): +class CustomDomainValidateResult(_serialization.Model): """Validation result for custom domain. :ivar is_valid: Indicates if domain name is valid. @@ -2810,29 +2602,23 @@ class CustomDomainValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'message': {'key': 'message', 'type': 'str'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - is_valid: Optional[bool] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, is_valid: Optional[bool] = None, message: Optional[str] = None, **kwargs): """ :keyword is_valid: Indicates if domain name is valid. :paramtype is_valid: bool :keyword message: Message of why domain name is invalid. :paramtype message: str """ - super(CustomDomainValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.message = message -class DeploymentInstance(msrest.serialization.Model): +class DeploymentInstance(_serialization.Model): """Deployment instance payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2852,30 +2638,26 @@ class DeploymentInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, - 'reason': {'readonly': True}, - 'discovery_status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'zone': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, + "reason": {"readonly": True}, + "discovery_status": {"readonly": True}, + "start_time": {"readonly": True}, + "zone": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'discovery_status': {'key': 'discoveryStatus', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'zone': {'key': 'zone', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "discovery_status": {"key": "discoveryStatus", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, + "zone": {"key": "zone", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None self.reason = None @@ -2904,26 +2686,26 @@ class DeploymentResource(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': 'DeploymentResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "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": "DeploymentResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( self, *, - properties: Optional["DeploymentResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.DeploymentResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -2932,12 +2714,12 @@ def __init__( :keyword sku: Sku of the Deployment resource. :paramtype sku: ~azure.mgmt.appplatform.v2022_04_01.models.Sku """ - super(DeploymentResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.sku = sku -class DeploymentResourceCollection(msrest.serialization.Model): +class DeploymentResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of Deployment resources. @@ -2948,16 +2730,12 @@ class DeploymentResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["DeploymentResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.DeploymentResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Deployment resources. @@ -2966,12 +2744,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(DeploymentResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class DeploymentResourceProperties(msrest.serialization.Model): +class DeploymentResourceProperties(_serialization.Model): """Deployment resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -2980,11 +2758,11 @@ class DeploymentResourceProperties(msrest.serialization.Model): :vartype source: ~azure.mgmt.appplatform.v2022_04_01.models.UserSourceInfo :ivar deployment_settings: Deployment settings of the Deployment. :vartype deployment_settings: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentSettings - :ivar provisioning_state: Provisioning state of the Deployment. Possible values include: - "Creating", "Updating", "Succeeded", "Failed". + :ivar provisioning_state: Provisioning state of the Deployment. Known values are: "Creating", + "Updating", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResourceProvisioningState - :ivar status: Status of the Deployment. Possible values include: "Stopped", "Running". + :ivar status: Status of the Deployment. Known values are: "Stopped" and "Running". :vartype status: str or ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResourceStatus :ivar active: Indicates whether the Deployment is active. :vartype active: bool @@ -2993,25 +2771,25 @@ class DeploymentResourceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'UserSourceInfo'}, - 'deployment_settings': {'key': 'deploymentSettings', 'type': 'DeploymentSettings'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'active': {'key': 'active', 'type': 'bool'}, - 'instances': {'key': 'instances', 'type': '[DeploymentInstance]'}, + "source": {"key": "source", "type": "UserSourceInfo"}, + "deployment_settings": {"key": "deploymentSettings", "type": "DeploymentSettings"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "active": {"key": "active", "type": "bool"}, + "instances": {"key": "instances", "type": "[DeploymentInstance]"}, } def __init__( self, *, - source: Optional["UserSourceInfo"] = None, - deployment_settings: Optional["DeploymentSettings"] = None, + source: Optional["_models.UserSourceInfo"] = None, + deployment_settings: Optional["_models.DeploymentSettings"] = None, active: Optional[bool] = None, **kwargs ): @@ -3023,7 +2801,7 @@ def __init__( :keyword active: Indicates whether the Deployment is active. :paramtype active: bool """ - super(DeploymentResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.deployment_settings = deployment_settings self.provisioning_state = None @@ -3032,7 +2810,7 @@ def __init__( self.instances = None -class DeploymentSettings(msrest.serialization.Model): +class DeploymentSettings(_serialization.Model): """Deployment settings payload. :ivar resource_requests: The requested resource quantity for required CPU and Memory. It is @@ -3042,21 +2820,21 @@ class DeploymentSettings(msrest.serialization.Model): :ivar environment_variables: Collection of environment variables. :vartype environment_variables: dict[str, str] :ivar addon_configs: Collection of addons. - :vartype addon_configs: dict[str, dict[str, any]] + :vartype addon_configs: dict[str, dict[str, JSON]] """ _attribute_map = { - 'resource_requests': {'key': 'resourceRequests', 'type': 'ResourceRequests'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '{str}'}, - 'addon_configs': {'key': 'addonConfigs', 'type': '{{object}}'}, + "resource_requests": {"key": "resourceRequests", "type": "ResourceRequests"}, + "environment_variables": {"key": "environmentVariables", "type": "{str}"}, + "addon_configs": {"key": "addonConfigs", "type": "{{object}}"}, } def __init__( self, *, - resource_requests: Optional["ResourceRequests"] = None, + resource_requests: Optional["_models.ResourceRequests"] = None, environment_variables: Optional[Dict[str, str]] = None, - addon_configs: Optional[Dict[str, Dict[str, Any]]] = None, + addon_configs: Optional[Dict[str, Dict[str, JSON]]] = None, **kwargs ): """ @@ -3067,15 +2845,15 @@ def __init__( :keyword environment_variables: Collection of environment variables. :paramtype environment_variables: dict[str, str] :keyword addon_configs: Collection of addons. - :paramtype addon_configs: dict[str, dict[str, any]] + :paramtype addon_configs: dict[str, dict[str, JSON]] """ - super(DeploymentSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_requests = resource_requests self.environment_variables = environment_variables self.addon_configs = addon_configs -class DiagnosticParameters(msrest.serialization.Model): +class DiagnosticParameters(_serialization.Model): """Diagnostic parameters of diagnostic operations. :ivar app_instance: App instance name. @@ -3087,9 +2865,9 @@ class DiagnosticParameters(msrest.serialization.Model): """ _attribute_map = { - 'app_instance': {'key': 'appInstance', 'type': 'str'}, - 'file_path': {'key': 'filePath', 'type': 'str'}, - 'duration': {'key': 'duration', 'type': 'str'}, + "app_instance": {"key": "appInstance", "type": "str"}, + "file_path": {"key": "filePath", "type": "str"}, + "duration": {"key": "duration", "type": "str"}, } def __init__( @@ -3108,13 +2886,13 @@ def __init__( :keyword duration: Duration of your JFR. 1 min can be represented by 1m or 60s. :paramtype duration: str """ - super(DiagnosticParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.app_instance = app_instance self.file_path = file_path self.duration = duration -class Error(msrest.serialization.Model): +class Error(_serialization.Model): """The error code compose of code and message. :ivar code: The code of error. @@ -3124,38 +2902,32 @@ class Error(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: The code of error. :paramtype code: str :keyword message: The message of error. :paramtype message: str """ - super(Error, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class GitPatternRepository(msrest.serialization.Model): +class GitPatternRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes """Git repository property payload for config server. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the repository. + :ivar name: Name of the repository. Required. :vartype name: str :ivar pattern: Collection of pattern of the repository. :vartype pattern: list[str] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -3176,22 +2948,22 @@ class GitPatternRepository(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'uri': {'required': True}, + "name": {"required": True}, + "uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'pattern': {'key': 'pattern', 'type': '[str]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "pattern": {"key": "pattern", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( @@ -3211,11 +2983,11 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of the repository. + :keyword name: Name of the repository. Required. :paramtype name: str :keyword pattern: Collection of pattern of the repository. :paramtype pattern: list[str] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -3234,7 +3006,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(GitPatternRepository, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.pattern = pattern self.uri = uri @@ -3251,12 +3023,12 @@ def __init__( class UploadedUserSourceInfo(UserSourceInfo): """Source with uploaded location. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: JarUploadedUserSourceInfo, NetCoreZipUploadedUserSourceInfo, SourceUploadedUserSourceInfo. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + JarUploadedUserSourceInfo, NetCoreZipUploadedUserSourceInfo, SourceUploadedUserSourceInfo All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -3265,34 +3037,32 @@ class UploadedUserSourceInfo(UserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, } _subtype_map = { - 'type': {'Jar': 'JarUploadedUserSourceInfo', 'NetCoreZip': 'NetCoreZipUploadedUserSourceInfo', 'Source': 'SourceUploadedUserSourceInfo'} + "type": { + "Jar": "JarUploadedUserSourceInfo", + "NetCoreZip": "NetCoreZipUploadedUserSourceInfo", + "Source": "SourceUploadedUserSourceInfo", + } } - def __init__( - self, - *, - version: Optional[str] = None, - relative_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, version: Optional[str] = None, relative_path: Optional[str] = None, **kwargs): """ :keyword version: Version of the source. :paramtype version: str :keyword relative_path: Relative path of the storage which stores the source. :paramtype relative_path: str """ - super(UploadedUserSourceInfo, self).__init__(version=version, **kwargs) - self.type = 'UploadedUserSourceInfo' # type: str + super().__init__(version=version, **kwargs) + self.type = "UploadedUserSourceInfo" # type: str self.relative_path = relative_path @@ -3301,7 +3071,7 @@ class JarUploadedUserSourceInfo(UploadedUserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -3314,15 +3084,15 @@ class JarUploadedUserSourceInfo(UploadedUserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, - 'jvm_options': {'key': 'jvmOptions', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, + "jvm_options": {"key": "jvmOptions", "type": "str"}, } def __init__( @@ -3344,20 +3114,20 @@ def __init__( :keyword jvm_options: JVM parameter. :paramtype jvm_options: str """ - super(JarUploadedUserSourceInfo, self).__init__(version=version, relative_path=relative_path, **kwargs) - self.type = 'Jar' # type: str + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "Jar" # type: str self.runtime_version = runtime_version self.jvm_options = jvm_options -class KeyVaultCertificateProperties(CertificateProperties): +class KeyVaultCertificateProperties(CertificateProperties): # pylint: disable=too-many-instance-attributes """Properties of certificate imported from key vault. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -3373,9 +3143,9 @@ class KeyVaultCertificateProperties(CertificateProperties): :vartype subject_name: str :ivar dns_names: The domain list of certificate. :vartype dns_names: list[str] - :ivar vault_uri: Required. The vault uri of user key vault. + :ivar vault_uri: The vault uri of user key vault. Required. :vartype vault_uri: str - :ivar key_vault_cert_name: Required. The certificate name of key vault. + :ivar key_vault_cert_name: The certificate name of key vault. Required. :vartype key_vault_cert_name: str :ivar cert_version: The certificate version of key vault. :vartype cert_version: str @@ -3385,31 +3155,31 @@ class KeyVaultCertificateProperties(CertificateProperties): """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, - 'vault_uri': {'required': True}, - 'key_vault_cert_name': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, - 'vault_uri': {'key': 'vaultUri', 'type': 'str'}, - 'key_vault_cert_name': {'key': 'keyVaultCertName', 'type': 'str'}, - 'cert_version': {'key': 'certVersion', 'type': 'str'}, - 'exclude_private_key': {'key': 'excludePrivateKey', 'type': 'bool'}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, + "vault_uri": {"required": True}, + "key_vault_cert_name": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "vault_uri": {"key": "vaultUri", "type": "str"}, + "key_vault_cert_name": {"key": "keyVaultCertName", "type": "str"}, + "cert_version": {"key": "certVersion", "type": "str"}, + "exclude_private_key": {"key": "excludePrivateKey", "type": "bool"}, } def __init__( @@ -3418,13 +3188,13 @@ def __init__( vault_uri: str, key_vault_cert_name: str, cert_version: Optional[str] = None, - exclude_private_key: Optional[bool] = False, + exclude_private_key: bool = False, **kwargs ): """ - :keyword vault_uri: Required. The vault uri of user key vault. + :keyword vault_uri: The vault uri of user key vault. Required. :paramtype vault_uri: str - :keyword key_vault_cert_name: Required. The certificate name of key vault. + :keyword key_vault_cert_name: The certificate name of key vault. Required. :paramtype key_vault_cert_name: str :keyword cert_version: The certificate version of key vault. :paramtype cert_version: str @@ -3432,20 +3202,20 @@ def __init__( vault. :paramtype exclude_private_key: bool """ - super(KeyVaultCertificateProperties, self).__init__(**kwargs) - self.type = 'KeyVaultCertificate' # type: str + super().__init__(**kwargs) + self.type = "KeyVaultCertificate" # type: str self.vault_uri = vault_uri self.key_vault_cert_name = key_vault_cert_name self.cert_version = cert_version self.exclude_private_key = exclude_private_key -class LoadedCertificate(msrest.serialization.Model): +class LoadedCertificate(_serialization.Model): """Loaded certificate payload. All required parameters must be populated in order to send to Azure. - :ivar resource_id: Required. Resource Id of loaded certificate. + :ivar resource_id: Resource Id of loaded certificate. Required. :vartype resource_id: str :ivar load_trust_store: Indicate whether the certificate will be loaded into default trust store, only work for Java runtime. @@ -3453,65 +3223,54 @@ class LoadedCertificate(msrest.serialization.Model): """ _validation = { - 'resource_id': {'required': True}, + "resource_id": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'load_trust_store': {'key': 'loadTrustStore', 'type': 'bool'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "load_trust_store": {"key": "loadTrustStore", "type": "bool"}, } - def __init__( - self, - *, - resource_id: str, - load_trust_store: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, resource_id: str, load_trust_store: bool = False, **kwargs): """ - :keyword resource_id: Required. Resource Id of loaded certificate. + :keyword resource_id: Resource Id of loaded certificate. Required. :paramtype resource_id: str :keyword load_trust_store: Indicate whether the certificate will be loaded into default trust store, only work for Java runtime. :paramtype load_trust_store: bool """ - super(LoadedCertificate, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.load_trust_store = load_trust_store -class LogFileUrlResponse(msrest.serialization.Model): +class LogFileUrlResponse(_serialization.Model): """Log file URL payload. All required parameters must be populated in order to send to Azure. - :ivar url: Required. URL of the log file. + :ivar url: URL of the log file. Required. :vartype url: str """ _validation = { - 'url': {'required': True}, + "url": {"required": True}, } _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, } - def __init__( - self, - *, - url: str, - **kwargs - ): + def __init__(self, *, url: str, **kwargs): """ - :keyword url: Required. URL of the log file. + :keyword url: URL of the log file. Required. :paramtype url: str """ - super(LogFileUrlResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url -class LogSpecification(msrest.serialization.Model): +class LogSpecification(_serialization.Model): """Specifications of the Log for Azure Monitoring. :ivar name: Name of the log. @@ -3523,9 +3282,9 @@ class LogSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, } def __init__( @@ -3544,17 +3303,17 @@ def __init__( :keyword blob_duration: Blob duration of the log. :paramtype blob_duration: str """ - super(LogSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class ManagedIdentityProperties(msrest.serialization.Model): +class ManagedIdentityProperties(_serialization.Model): """Managed identity properties retrieved from ARM request headers. - :ivar type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.appplatform.v2022_04_01.models.ManagedIdentityType :ivar principal_id: Principal Id of system-assigned managed identity. :vartype principal_id: str @@ -3563,35 +3322,35 @@ class ManagedIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ManagedIdentityType"]] = None, + type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs ): """ - :keyword type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.appplatform.v2022_04_01.models.ManagedIdentityType :keyword principal_id: Principal Id of system-assigned managed identity. :paramtype principal_id: str :keyword tenant_id: Tenant Id of system-assigned managed identity. :paramtype tenant_id: str """ - super(ManagedIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.principal_id = principal_id self.tenant_id = tenant_id -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """Specifications of the Dimension of metrics. :ivar name: Name of the dimension. @@ -3604,9 +3363,9 @@ class MetricDimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -3626,13 +3385,13 @@ def __init__( export scenario. :paramtype to_be_exported_for_shoebox: bool """ - super(MetricDimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes """Specifications of the Metrics for Azure Monitoring. :ivar name: Name of the metric. @@ -3663,17 +3422,17 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "source_mdm_namespace": {"key": "sourceMdmNamespace", "type": "str"}, } def __init__( @@ -3688,7 +3447,7 @@ def __init__( supported_aggregation_types: Optional[List[str]] = None, supported_time_grain_types: Optional[List[str]] = None, fill_gap_with_zero: Optional[bool] = None, - dimensions: Optional[List["MetricDimension"]] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, source_mdm_namespace: Optional[str] = None, **kwargs ): @@ -3719,7 +3478,7 @@ def __init__( :keyword source_mdm_namespace: Name of the MDM namespace. Optional. :paramtype source_mdm_namespace: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -3733,13 +3492,13 @@ def __init__( self.source_mdm_namespace = source_mdm_namespace -class MonitoringSettingProperties(msrest.serialization.Model): +class MonitoringSettingProperties(_serialization.Model): """Monitoring Setting properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Monitoring Setting. Possible values include: - "NotAvailable", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the Monitoring Setting. Known values are: "NotAvailable", + "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingState :ivar error: Error when apply Monitoring Setting changes. @@ -3760,27 +3519,27 @@ class MonitoringSettingProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'app_insights_sampling_rate': {'maximum': 100, 'minimum': 0}, + "provisioning_state": {"readonly": True}, + "app_insights_sampling_rate": {"maximum": 100, "minimum": 0}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'trace_enabled': {'key': 'traceEnabled', 'type': 'bool'}, - 'app_insights_instrumentation_key': {'key': 'appInsightsInstrumentationKey', 'type': 'str'}, - 'app_insights_sampling_rate': {'key': 'appInsightsSamplingRate', 'type': 'float'}, - 'app_insights_agent_versions': {'key': 'appInsightsAgentVersions', 'type': 'ApplicationInsightsAgentVersions'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "trace_enabled": {"key": "traceEnabled", "type": "bool"}, + "app_insights_instrumentation_key": {"key": "appInsightsInstrumentationKey", "type": "str"}, + "app_insights_sampling_rate": {"key": "appInsightsSamplingRate", "type": "float"}, + "app_insights_agent_versions": {"key": "appInsightsAgentVersions", "type": "ApplicationInsightsAgentVersions"}, } def __init__( self, *, - error: Optional["Error"] = None, + error: Optional["_models.Error"] = None, trace_enabled: Optional[bool] = None, app_insights_instrumentation_key: Optional[str] = None, app_insights_sampling_rate: Optional[float] = None, - app_insights_agent_versions: Optional["ApplicationInsightsAgentVersions"] = None, + app_insights_agent_versions: Optional["_models.ApplicationInsightsAgentVersions"] = None, **kwargs ): """ @@ -3800,7 +3559,7 @@ def __init__( :paramtype app_insights_agent_versions: ~azure.mgmt.appplatform.v2022_04_01.models.ApplicationInsightsAgentVersions """ - super(MonitoringSettingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.trace_enabled = trace_enabled @@ -3827,35 +3586,30 @@ class MonitoringSettingResource(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': 'MonitoringSettingProperties'}, + "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": "MonitoringSettingProperties"}, } - def __init__( - self, - *, - properties: Optional["MonitoringSettingProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.MonitoringSettingProperties"] = None, **kwargs): """ :keyword properties: Properties of the Monitoring Setting resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingProperties """ - super(MonitoringSettingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class NameAvailability(msrest.serialization.Model): +class NameAvailability(_serialization.Model): """Name availability result payload. :ivar name_available: Indicates whether the name is available. @@ -3867,9 +3621,9 @@ class NameAvailability(msrest.serialization.Model): """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } def __init__( @@ -3888,47 +3642,41 @@ def __init__( :keyword message: Message why the name is not available. :paramtype message: str """ - super(NameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class NameAvailabilityParameters(msrest.serialization.Model): +class NameAvailabilityParameters(_serialization.Model): """Name availability parameters payload. All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the resource to check name availability. + :ivar type: Type of the resource to check name availability. Required. :vartype type: str - :ivar name: Required. Name to be checked. + :ivar name: Name to be checked. Required. :vartype name: str """ _validation = { - 'type': {'required': True}, - 'name': {'required': True}, + "type": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - type: str, - name: str, - **kwargs - ): + def __init__(self, *, type: str, name: str, **kwargs): """ - :keyword type: Required. Type of the resource to check name availability. + :keyword type: Type of the resource to check name availability. Required. :paramtype type: str - :keyword name: Required. Name to be checked. + :keyword name: Name to be checked. Required. :paramtype name: str """ - super(NameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name @@ -3938,7 +3686,7 @@ class NetCoreZipUploadedUserSourceInfo(UploadedUserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -3951,15 +3699,15 @@ class NetCoreZipUploadedUserSourceInfo(UploadedUserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'net_core_main_entry_path': {'key': 'netCoreMainEntryPath', 'type': 'str'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "net_core_main_entry_path": {"key": "netCoreMainEntryPath", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, } def __init__( @@ -3981,13 +3729,13 @@ def __init__( :keyword runtime_version: Runtime version of the .Net file. :paramtype runtime_version: str """ - super(NetCoreZipUploadedUserSourceInfo, self).__init__(version=version, relative_path=relative_path, **kwargs) - self.type = 'NetCoreZip' # type: str + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "NetCoreZip" # type: str self.net_core_main_entry_path = net_core_main_entry_path self.runtime_version = runtime_version -class NetworkProfile(msrest.serialization.Model): +class NetworkProfile(_serialization.Model): """Service network profile payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -4013,18 +3761,18 @@ class NetworkProfile(msrest.serialization.Model): """ _validation = { - 'outbound_i_ps': {'readonly': True}, - 'required_traffics': {'readonly': True}, + "outbound_i_ps": {"readonly": True}, + "required_traffics": {"readonly": True}, } _attribute_map = { - 'service_runtime_subnet_id': {'key': 'serviceRuntimeSubnetId', 'type': 'str'}, - 'app_subnet_id': {'key': 'appSubnetId', 'type': 'str'}, - 'service_cidr': {'key': 'serviceCidr', 'type': 'str'}, - 'service_runtime_network_resource_group': {'key': 'serviceRuntimeNetworkResourceGroup', 'type': 'str'}, - 'app_network_resource_group': {'key': 'appNetworkResourceGroup', 'type': 'str'}, - 'outbound_i_ps': {'key': 'outboundIPs', 'type': 'NetworkProfileOutboundIPs'}, - 'required_traffics': {'key': 'requiredTraffics', 'type': '[RequiredTraffic]'}, + "service_runtime_subnet_id": {"key": "serviceRuntimeSubnetId", "type": "str"}, + "app_subnet_id": {"key": "appSubnetId", "type": "str"}, + "service_cidr": {"key": "serviceCidr", "type": "str"}, + "service_runtime_network_resource_group": {"key": "serviceRuntimeNetworkResourceGroup", "type": "str"}, + "app_network_resource_group": {"key": "appNetworkResourceGroup", "type": "str"}, + "outbound_i_ps": {"key": "outboundIPs", "type": "NetworkProfileOutboundIPs"}, + "required_traffics": {"key": "requiredTraffics", "type": "[RequiredTraffic]"}, } def __init__( @@ -4053,7 +3801,7 @@ def __init__( for customer apps in Azure Spring Apps. :paramtype app_network_resource_group: str """ - super(NetworkProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_runtime_subnet_id = service_runtime_subnet_id self.app_subnet_id = app_subnet_id self.service_cidr = service_cidr @@ -4063,7 +3811,7 @@ def __init__( self.required_traffics = None -class NetworkProfileOutboundIPs(msrest.serialization.Model): +class NetworkProfileOutboundIPs(_serialization.Model): """Desired outbound IP resources for Azure Spring Apps resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -4073,24 +3821,20 @@ class NetworkProfileOutboundIPs(msrest.serialization.Model): """ _validation = { - 'public_i_ps': {'readonly': True}, + "public_i_ps": {"readonly": True}, } _attribute_map = { - 'public_i_ps': {'key': 'publicIPs', 'type': '[str]'}, + "public_i_ps": {"key": "publicIPs", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(NetworkProfileOutboundIPs, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.public_i_ps = None -class OperationDetail(msrest.serialization.Model): +class OperationDetail(_serialization.Model): """Operation detail payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -4102,7 +3846,7 @@ class OperationDetail(msrest.serialization.Model): :ivar display: Display of the operation. :vartype display: ~azure.mgmt.appplatform.v2022_04_01.models.OperationDisplay :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. Possible values include: "Internal". + internal only APIs. "Internal" :vartype action_type: str or ~azure.mgmt.appplatform.v2022_04_01.models.ActionType :ivar origin: Origin of the operation. :vartype origin: str @@ -4111,16 +3855,16 @@ class OperationDetail(msrest.serialization.Model): """ _validation = { - 'action_type': {'readonly': True}, + "action_type": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'action_type': {'key': 'actionType', 'type': 'str'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "action_type": {"key": "actionType", "type": "str"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "OperationProperties"}, } def __init__( @@ -4128,9 +3872,9 @@ 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, - properties: Optional["OperationProperties"] = None, + properties: Optional["_models.OperationProperties"] = None, **kwargs ): """ @@ -4145,7 +3889,7 @@ def __init__( :keyword properties: Properties of the operation. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.OperationProperties """ - super(OperationDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display @@ -4154,7 +3898,7 @@ def __init__( self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display payload. :ivar provider: Resource provider of the operation. @@ -4168,10 +3912,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__( @@ -4193,14 +3937,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 OperationProperties(msrest.serialization.Model): +class OperationProperties(_serialization.Model): """Extra Operation properties. :ivar service_specification: Service specifications of the operation. @@ -4208,25 +3952,20 @@ class OperationProperties(msrest.serialization.Model): """ _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, } - def __init__( - self, - *, - service_specification: Optional["ServiceSpecification"] = None, - **kwargs - ): + def __init__(self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs): """ :keyword service_specification: Service specifications of the operation. :paramtype service_specification: ~azure.mgmt.appplatform.v2022_04_01.models.ServiceSpecification """ - super(OperationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_specification = service_specification -class PersistentDisk(msrest.serialization.Model): +class PersistentDisk(_serialization.Model): """Persistent disk payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -4240,69 +3979,56 @@ class PersistentDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 50, 'minimum': 0}, - 'used_in_gb': {'readonly': True, 'maximum': 50, 'minimum': 0}, + "size_in_gb": {"maximum": 50, "minimum": 0}, + "used_in_gb": {"readonly": True, "maximum": 50, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'used_in_gb': {'key': 'usedInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "used_in_gb": {"key": "usedInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: Optional[str] = None, **kwargs): """ :keyword size_in_gb: Size of the persistent disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the persistent disk. :paramtype mount_path: str """ - super(PersistentDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.used_in_gb = None self.mount_path = mount_path -class RegenerateTestKeyRequestPayload(msrest.serialization.Model): +class RegenerateTestKeyRequestPayload(_serialization.Model): """Regenerate test key request payload. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :ivar key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :vartype key_type: str or ~azure.mgmt.appplatform.v2022_04_01.models.TestKeyType """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "TestKeyType"], - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.TestKeyType"], **kwargs): """ - :keyword key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :keyword key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :paramtype key_type: str or ~azure.mgmt.appplatform.v2022_04_01.models.TestKeyType """ - super(RegenerateTestKeyRequestPayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type -class RequiredTraffic(msrest.serialization.Model): +class RequiredTraffic(_serialization.Model): """Required inbound or outbound traffic for Azure Spring Apps resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -4315,34 +4041,29 @@ class RequiredTraffic(msrest.serialization.Model): :vartype ips: list[str] :ivar fqdns: The FQDN list of required traffic. :vartype fqdns: list[str] - :ivar direction: The direction of required traffic. Possible values include: "Inbound", - "Outbound". + :ivar direction: The direction of required traffic. Known values are: "Inbound" and "Outbound". :vartype direction: str or ~azure.mgmt.appplatform.v2022_04_01.models.TrafficDirection """ _validation = { - 'protocol': {'readonly': True}, - 'port': {'readonly': True}, - 'ips': {'readonly': True}, - 'fqdns': {'readonly': True}, - 'direction': {'readonly': True}, + "protocol": {"readonly": True}, + "port": {"readonly": True}, + "ips": {"readonly": True}, + "fqdns": {"readonly": True}, + "direction": {"readonly": True}, } _attribute_map = { - 'protocol': {'key': 'protocol', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - 'ips': {'key': 'ips', 'type': '[str]'}, - 'fqdns': {'key': 'fqdns', 'type': '[str]'}, - 'direction': {'key': 'direction', 'type': 'str'}, + "protocol": {"key": "protocol", "type": "str"}, + "port": {"key": "port", "type": "int"}, + "ips": {"key": "ips", "type": "[str]"}, + "fqdns": {"key": "fqdns", "type": "[str]"}, + "direction": {"key": "direction", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RequiredTraffic, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.protocol = None self.port = None self.ips = None @@ -4350,7 +4071,7 @@ def __init__( self.direction = None -class ResourceRequests(msrest.serialization.Model): +class ResourceRequests(_serialization.Model): """Deployment resource request payload. :ivar cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 for @@ -4362,17 +4083,11 @@ class ResourceRequests(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - *, - cpu: Optional[str] = None, - memory: Optional[str] = None, - **kwargs - ): + def __init__(self, *, cpu: Optional[str] = None, memory: Optional[str] = None, **kwargs): """ :keyword cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 for Basic tier, and {500m, 1, 2, 3, 4} for Standard tier. @@ -4381,12 +4096,12 @@ def __init__( {512Mi, 1Gi, 2Gi} for Basic tier, and {512Mi, 1Gi, 2Gi, ..., 8Gi} for Standard tier. :paramtype memory: str """ - super(ResourceRequests, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory = memory -class ResourceSku(msrest.serialization.Model): +class ResourceSku(_serialization.Model): """Describes an available Azure Spring Apps SKU. :ivar resource_type: Gets the type of resource the SKU applies to. @@ -4409,13 +4124,13 @@ class ResourceSku(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'SkuCapacity'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[ResourceSkuLocationInfo]'}, - 'restrictions': {'key': 'restrictions', 'type': '[ResourceSkuRestrictions]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "SkuCapacity"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[ResourceSkuLocationInfo]"}, + "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, } def __init__( @@ -4424,10 +4139,10 @@ def __init__( resource_type: Optional[str] = None, name: Optional[str] = None, tier: Optional[str] = None, - capacity: Optional["SkuCapacity"] = None, + capacity: Optional["_models.SkuCapacity"] = None, locations: Optional[List[str]] = None, - location_info: Optional[List["ResourceSkuLocationInfo"]] = None, - restrictions: Optional[List["ResourceSkuRestrictions"]] = None, + location_info: Optional[List["_models.ResourceSkuLocationInfo"]] = None, + restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None, **kwargs ): """ @@ -4450,7 +4165,7 @@ def __init__( :paramtype restrictions: list[~azure.mgmt.appplatform.v2022_04_01.models.ResourceSkuRestrictions] """ - super(ResourceSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.name = name self.tier = tier @@ -4460,7 +4175,7 @@ def __init__( self.restrictions = restrictions -class ResourceSkuCapabilities(msrest.serialization.Model): +class ResourceSkuCapabilities(_serialization.Model): """ResourceSkuCapabilities. :ivar name: Gets an invariant to describe the feature. @@ -4470,29 +4185,23 @@ class ResourceSkuCapabilities(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: Gets an invariant to describe the feature. :paramtype name: str :keyword value: Gets an invariant if the feature is measured by quantity. :paramtype value: str """ - super(ResourceSkuCapabilities, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class ResourceSkuCollection(msrest.serialization.Model): +class ResourceSkuCollection(_serialization.Model): """Object that includes an array of Azure Spring Apps SKU and a possible link for next set. :ivar value: Collection of resource SKU. @@ -4503,16 +4212,12 @@ class ResourceSkuCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ResourceSku"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ResourceSku"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of resource SKU. @@ -4521,12 +4226,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ResourceSkuCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ResourceSkuLocationInfo(msrest.serialization.Model): +class ResourceSkuLocationInfo(_serialization.Model): """Locations and availability zones where the SKU is available. :ivar location: Gets location of the SKU. @@ -4538,9 +4243,9 @@ class ResourceSkuLocationInfo(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'zone_details': {'key': 'zoneDetails', 'type': '[ResourceSkuZoneDetails]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "zone_details": {"key": "zoneDetails", "type": "[ResourceSkuZoneDetails]"}, } def __init__( @@ -4548,7 +4253,7 @@ def __init__( *, location: Optional[str] = None, zones: Optional[List[str]] = None, - zone_details: Optional[List["ResourceSkuZoneDetails"]] = None, + zone_details: Optional[List["_models.ResourceSkuZoneDetails"]] = None, **kwargs ): """ @@ -4560,13 +4265,13 @@ def __init__( :paramtype zone_details: list[~azure.mgmt.appplatform.v2022_04_01.models.ResourceSkuZoneDetails] """ - super(ResourceSkuLocationInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones self.zone_details = zone_details -class ResourceSkuRestrictionInfo(msrest.serialization.Model): +class ResourceSkuRestrictionInfo(_serialization.Model): """Information about the restriction where the SKU cannot be used. :ivar locations: Gets locations where the SKU is restricted. @@ -4576,33 +4281,27 @@ class ResourceSkuRestrictionInfo(msrest.serialization.Model): """ _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - locations: Optional[List[str]] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, locations: Optional[List[str]] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword locations: Gets locations where the SKU is restricted. :paramtype locations: list[str] :keyword zones: Gets list of availability zones where the SKU is restricted. :paramtype zones: list[str] """ - super(ResourceSkuRestrictionInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.locations = locations self.zones = zones -class ResourceSkuRestrictions(msrest.serialization.Model): +class ResourceSkuRestrictions(_serialization.Model): """Restrictions where the SKU cannot be used. - :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. Known + values are: "Location" and "Zone". :vartype type: str or ~azure.mgmt.appplatform.v2022_04_01.models.ResourceSkuRestrictionsType :ivar values: Gets the value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted. @@ -4612,31 +4311,30 @@ class ResourceSkuRestrictions(msrest.serialization.Model): :vartype restriction_info: ~azure.mgmt.appplatform.v2022_04_01.models.ResourceSkuRestrictionInfo :ivar reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.appplatform.v2022_04_01.models.ResourceSkuRestrictionsReasonCode """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'ResourceSkuRestrictionInfo'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "restriction_info": {"key": "restrictionInfo", "type": "ResourceSkuRestrictionInfo"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceSkuRestrictionsType"]] = None, + type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None, values: Optional[List[str]] = None, - restriction_info: Optional["ResourceSkuRestrictionInfo"] = None, - reason_code: Optional[Union[str, "ResourceSkuRestrictionsReasonCode"]] = None, + restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None, + reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None, **kwargs ): """ :keyword type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + Known values are: "Location" and "Zone". :paramtype type: str or ~azure.mgmt.appplatform.v2022_04_01.models.ResourceSkuRestrictionsType :keyword values: Gets the value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted. @@ -4646,19 +4344,18 @@ def __init__( :paramtype restriction_info: ~azure.mgmt.appplatform.v2022_04_01.models.ResourceSkuRestrictionInfo :keyword reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.appplatform.v2022_04_01.models.ResourceSkuRestrictionsReasonCode """ - super(ResourceSkuRestrictions, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.values = values self.restriction_info = restriction_info self.reason_code = reason_code -class ResourceSkuZoneDetails(msrest.serialization.Model): +class ResourceSkuZoneDetails(_serialization.Model): """Details of capabilities available to a SKU in specific zones. :ivar name: Gets the set of zones that the SKU is available in with the @@ -4670,15 +4367,15 @@ class ResourceSkuZoneDetails(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[ResourceSkuCapabilities]'}, + "name": {"key": "name", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, } def __init__( self, *, name: Optional[List[str]] = None, - capabilities: Optional[List["ResourceSkuCapabilities"]] = None, + capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None, **kwargs ): """ @@ -4690,12 +4387,12 @@ def __init__( :paramtype capabilities: list[~azure.mgmt.appplatform.v2022_04_01.models.ResourceSkuCapabilities] """ - super(ResourceSkuZoneDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.capabilities = capabilities -class ResourceUploadDefinition(msrest.serialization.Model): +class ResourceUploadDefinition(_serialization.Model): """Resource upload definition payload. :ivar relative_path: Source relative path. @@ -4705,29 +4402,23 @@ class ResourceUploadDefinition(msrest.serialization.Model): """ _attribute_map = { - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'upload_url': {'key': 'uploadUrl', 'type': 'str'}, + "relative_path": {"key": "relativePath", "type": "str"}, + "upload_url": {"key": "uploadUrl", "type": "str"}, } - def __init__( - self, - *, - relative_path: Optional[str] = None, - upload_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, relative_path: Optional[str] = None, upload_url: Optional[str] = None, **kwargs): """ :keyword relative_path: Source relative path. :paramtype relative_path: str :keyword upload_url: Upload URL. :paramtype upload_url: str """ - super(ResourceUploadDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.relative_path = relative_path self.upload_url = upload_url -class ServiceRegistryInstance(msrest.serialization.Model): +class ServiceRegistryInstance(_serialization.Model): """Collection of instances belong to the Service Registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -4739,33 +4430,29 @@ class ServiceRegistryInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServiceRegistryInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class ServiceRegistryProperties(msrest.serialization.Model): +class ServiceRegistryProperties(_serialization.Model): """Service Registry properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Service Registry. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Service Registry. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_04_01.models.ServiceRegistryProvisioningState :ivar resource_requests: The requested resource quantity for required CPU and Memory. @@ -4776,24 +4463,20 @@ class ServiceRegistryProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'resource_requests': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'ServiceRegistryResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[ServiceRegistryInstance]'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "ServiceRegistryResourceRequests"}, + "instances": {"key": "instances", "type": "[ServiceRegistryInstance]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServiceRegistryProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.resource_requests = None self.instances = None @@ -4817,35 +4500,30 @@ class ServiceRegistryResource(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': 'ServiceRegistryProperties'}, + "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": "ServiceRegistryProperties"}, } - def __init__( - self, - *, - properties: Optional["ServiceRegistryProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ServiceRegistryProperties"] = None, **kwargs): """ :keyword properties: Service Registry properties payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.ServiceRegistryProperties """ - super(ServiceRegistryResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ServiceRegistryResourceCollection(msrest.serialization.Model): +class ServiceRegistryResourceCollection(_serialization.Model): """Object that includes an array of Service Registry resources and a possible link for next set. :ivar value: Collection of Service Registry resources. @@ -4856,14 +4534,14 @@ class ServiceRegistryResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceRegistryResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServiceRegistryResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ServiceRegistryResource"]] = None, + value: Optional[List["_models.ServiceRegistryResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -4874,12 +4552,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ServiceRegistryResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServiceRegistryResourceRequests(msrest.serialization.Model): +class ServiceRegistryResourceRequests(_serialization.Model): """Resource request payload of Service Registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -4893,24 +4571,20 @@ class ServiceRegistryResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, - 'instance_count': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServiceRegistryResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None self.instance_count = None @@ -4931,42 +4605,35 @@ class TrackedResource(Resource): :vartype system_data: ~azure.mgmt.appplatform.v2022_04_01.models.SystemData :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] """ _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -4986,8 +4653,7 @@ class ServiceResource(TrackedResource): :vartype system_data: ~azure.mgmt.appplatform.v2022_04_01.models.SystemData :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] :ivar properties: Properties of the Service resource. :vartype properties: ~azure.mgmt.appplatform.v2022_04_01.models.ClusterResourceProperties @@ -4996,21 +4662,21 @@ class ServiceResource(TrackedResource): """ _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ClusterResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "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"}, + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "ClusterResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( @@ -5018,27 +4684,27 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - properties: Optional["ClusterResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.ClusterResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] :keyword properties: Properties of the Service resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.ClusterResourceProperties :keyword sku: Sku of the Service resource. :paramtype sku: ~azure.mgmt.appplatform.v2022_04_01.models.Sku """ - super(ServiceResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.properties = properties self.sku = sku -class ServiceResourceList(msrest.serialization.Model): +class ServiceResourceList(_serialization.Model): """Object that includes an array of Service resources and a possible link for next set. :ivar value: Collection of Service resources. @@ -5049,16 +4715,12 @@ class ServiceResourceList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ServiceResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ServiceResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Service resources. @@ -5067,12 +4729,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ServiceResourceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification payload. :ivar log_specifications: Specifications of the Log for Azure Monitoring. @@ -5083,15 +4745,15 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } def __init__( self, *, - log_specifications: Optional[List["LogSpecification"]] = None, - metric_specifications: Optional[List["MetricSpecification"]] = None, + log_specifications: Optional[List["_models.LogSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -5102,12 +4764,12 @@ def __init__( :paramtype metric_specifications: list[~azure.mgmt.appplatform.v2022_04_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_specifications = log_specifications self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """Sku of Azure Spring Apps. :ivar name: Name of the Sku. @@ -5119,19 +4781,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Optional[str] = "S0", - tier: Optional[str] = "Standard", - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: str = "S0", tier: str = "Standard", capacity: Optional[int] = None, **kwargs): """ :keyword name: Name of the Sku. :paramtype name: str @@ -5140,37 +4795,37 @@ def __init__( :keyword capacity: Current capacity of the target resource. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SkuCapacity(msrest.serialization.Model): +class SkuCapacity(_serialization.Model): """The SKU capacity. All required parameters must be populated in order to send to Azure. - :ivar minimum: Required. Gets or sets the minimum. + :ivar minimum: Gets or sets the minimum. Required. :vartype minimum: int :ivar maximum: Gets or sets the maximum. :vartype maximum: int :ivar default: Gets or sets the default. :vartype default: int - :ivar scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :ivar scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", and + "Automatic". :vartype scale_type: str or ~azure.mgmt.appplatform.v2022_04_01.models.SkuScaleType """ _validation = { - 'minimum': {'required': True}, + "minimum": {"required": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } def __init__( @@ -5179,21 +4834,21 @@ def __init__( minimum: int, maximum: Optional[int] = None, default: Optional[int] = None, - scale_type: Optional[Union[str, "SkuScaleType"]] = None, + scale_type: Optional[Union[str, "_models.SkuScaleType"]] = None, **kwargs ): """ - :keyword minimum: Required. Gets or sets the minimum. + :keyword minimum: Gets or sets the minimum. Required. :paramtype minimum: int :keyword maximum: Gets or sets the maximum. :paramtype maximum: int :keyword default: Gets or sets the default. :paramtype default: int - :keyword scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :keyword scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", + and "Automatic". :paramtype scale_type: str or ~azure.mgmt.appplatform.v2022_04_01.models.SkuScaleType """ - super(SkuCapacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.minimum = minimum self.maximum = maximum self.default = default @@ -5205,7 +4860,7 @@ class SourceUploadedUserSourceInfo(UploadedUserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -5220,15 +4875,15 @@ class SourceUploadedUserSourceInfo(UploadedUserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'artifact_selector': {'key': 'artifactSelector', 'type': 'str'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "artifact_selector": {"key": "artifactSelector", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, } def __init__( @@ -5252,13 +4907,13 @@ def __init__( :keyword runtime_version: Runtime version of the source file. :paramtype runtime_version: str """ - super(SourceUploadedUserSourceInfo, self).__init__(version=version, relative_path=relative_path, **kwargs) - self.type = 'Source' # type: str + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "Source" # type: str self.artifact_selector = artifact_selector self.runtime_version = runtime_version -class StackProperties(msrest.serialization.Model): +class StackProperties(_serialization.Model): """KPack ClusterStack properties payload. :ivar id: Id of the ClusterStack. @@ -5268,16 +4923,12 @@ class StackProperties(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( - self, - *, - id: Optional[str] = None, - version: Optional[str] = None, - **kwargs + self, *, id: Optional[str] = None, version: Optional[str] = None, **kwargs # pylint: disable=redefined-builtin ): """ :keyword id: Id of the ClusterStack. @@ -5285,7 +4936,7 @@ def __init__( :keyword version: Version of the ClusterStack. :paramtype version: str """ - super(StackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.version = version @@ -5309,36 +4960,31 @@ class SupportedBuildpackResource(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': 'SupportedBuildpackResourceProperties'}, + "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": "SupportedBuildpackResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["SupportedBuildpackResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.SupportedBuildpackResourceProperties"] = None, **kwargs): """ :keyword properties: Supported buildpack resource properties. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.SupportedBuildpackResourceProperties """ - super(SupportedBuildpackResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class SupportedBuildpackResourceProperties(msrest.serialization.Model): +class SupportedBuildpackResourceProperties(_serialization.Model): """Supported buildpack resource properties. :ivar buildpack_id: The id of supported buildpack. @@ -5346,24 +4992,19 @@ class SupportedBuildpackResourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'buildpack_id': {'key': 'buildpackId', 'type': 'str'}, + "buildpack_id": {"key": "buildpackId", "type": "str"}, } - def __init__( - self, - *, - buildpack_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, buildpack_id: Optional[str] = None, **kwargs): """ :keyword buildpack_id: The id of supported buildpack. :paramtype buildpack_id: str """ - super(SupportedBuildpackResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.buildpack_id = buildpack_id -class SupportedBuildpacksCollection(msrest.serialization.Model): +class SupportedBuildpacksCollection(_serialization.Model): """Object that includes an array of supported buildpacks resources and a possible link for next set. :ivar value: Collection of supported buildpacks resources. @@ -5374,14 +5015,14 @@ class SupportedBuildpacksCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedBuildpackResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SupportedBuildpackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["SupportedBuildpackResource"]] = None, + value: Optional[List["_models.SupportedBuildpackResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -5392,49 +5033,49 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(SupportedBuildpacksCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SupportedRuntimeVersion(msrest.serialization.Model): +class SupportedRuntimeVersion(_serialization.Model): """Supported deployment runtime version descriptor. - :ivar value: The raw value which could be passed to deployment CRUD operations. Possible values - include: "Java_8", "Java_11", "Java_17", "NetCore_31". + :ivar value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", "Java_17", and "NetCore_31". :vartype value: str or ~azure.mgmt.appplatform.v2022_04_01.models.SupportedRuntimeValue - :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). Known + values are: "Java" and ".NET Core". :vartype platform: str or ~azure.mgmt.appplatform.v2022_04_01.models.SupportedRuntimePlatform :ivar version: The detailed version (major.minor) of the platform. :vartype version: str """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'platform': {'key': 'platform', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "platform": {"key": "platform", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - value: Optional[Union[str, "SupportedRuntimeValue"]] = None, - platform: Optional[Union[str, "SupportedRuntimePlatform"]] = None, + value: Optional[Union[str, "_models.SupportedRuntimeValue"]] = None, + platform: Optional[Union[str, "_models.SupportedRuntimePlatform"]] = None, version: Optional[str] = None, **kwargs ): """ - :keyword value: The raw value which could be passed to deployment CRUD operations. Possible - values include: "Java_8", "Java_11", "Java_17", "NetCore_31". + :keyword value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", "Java_17", and "NetCore_31". :paramtype value: str or ~azure.mgmt.appplatform.v2022_04_01.models.SupportedRuntimeValue :keyword platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + Known values are: "Java" and ".NET Core". :paramtype platform: str or ~azure.mgmt.appplatform.v2022_04_01.models.SupportedRuntimePlatform :keyword version: The detailed version (major.minor) of the platform. :paramtype version: str """ - super(SupportedRuntimeVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.platform = platform self.version = version @@ -5459,36 +5100,31 @@ class SupportedStackResource(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': 'SupportedStackResourceProperties'}, + "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": "SupportedStackResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["SupportedStackResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.SupportedStackResourceProperties"] = None, **kwargs): """ :keyword properties: Supported stack resource properties. :paramtype properties: ~azure.mgmt.appplatform.v2022_04_01.models.SupportedStackResourceProperties """ - super(SupportedStackResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class SupportedStackResourceProperties(msrest.serialization.Model): +class SupportedStackResourceProperties(_serialization.Model): """Supported stack resource properties. :ivar stack_id: The id of supported stack. @@ -5498,29 +5134,23 @@ class SupportedStackResourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'stack_id': {'key': 'stackId', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "stack_id": {"key": "stackId", "type": "str"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - *, - stack_id: Optional[str] = None, - version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, stack_id: Optional[str] = None, version: Optional[str] = None, **kwargs): """ :keyword stack_id: The id of supported stack. :paramtype stack_id: str :keyword version: The version of supported stack. :paramtype version: str """ - super(SupportedStackResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.stack_id = stack_id self.version = version -class SupportedStacksCollection(msrest.serialization.Model): +class SupportedStacksCollection(_serialization.Model): """Object that includes an array of supported stacks resources and a possible link for next set. :ivar value: Collection of supported stacks resources. @@ -5531,14 +5161,14 @@ class SupportedStacksCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedStackResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SupportedStackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["SupportedStackResource"]] = None, + value: Optional[List["_models.SupportedStackResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -5549,25 +5179,25 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(SupportedStacksCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -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.appplatform.v2022_04_01.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.appplatform.v2022_04_01.models.LastModifiedByType :ivar last_modified_at: The timestamp of resource modification (UTC). @@ -5575,43 +5205,43 @@ class SystemData(msrest.serialization.Model): """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "LastModifiedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.appplatform.v2022_04_01.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.appplatform.v2022_04_01.models.LastModifiedByType :keyword last_modified_at: The timestamp of resource modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -5620,7 +5250,7 @@ def __init__( self.last_modified_at = last_modified_at -class TemporaryDisk(msrest.serialization.Model): +class TemporaryDisk(_serialization.Model): """Temporary disk payload. :ivar size_in_gb: Size of the temporary disk in GB. @@ -5630,33 +5260,27 @@ class TemporaryDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 5, 'minimum': 0}, + "size_in_gb": {"maximum": 5, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = "/tmp", - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: str = "/tmp", **kwargs): """ :keyword size_in_gb: Size of the temporary disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the temporary disk. :paramtype mount_path: str """ - super(TemporaryDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.mount_path = mount_path -class TestKeys(msrest.serialization.Model): +class TestKeys(_serialization.Model): """Test keys payload. :ivar primary_key: Primary key. @@ -5672,11 +5296,11 @@ class TestKeys(msrest.serialization.Model): """ _attribute_map = { - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'primary_test_endpoint': {'key': 'primaryTestEndpoint', 'type': 'str'}, - 'secondary_test_endpoint': {'key': 'secondaryTestEndpoint', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "primary_test_endpoint": {"key": "primaryTestEndpoint", "type": "str"}, + "secondary_test_endpoint": {"key": "secondaryTestEndpoint", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, } def __init__( @@ -5701,7 +5325,7 @@ def __init__( :keyword enabled: Indicates whether the test endpoint feature enabled or not. :paramtype enabled: bool """ - super(TestKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_key = primary_key self.secondary_key = secondary_key self.primary_test_endpoint = primary_test_endpoint @@ -5709,7 +5333,7 @@ def __init__( self.enabled = enabled -class TriggeredBuildResult(msrest.serialization.Model): +class TriggeredBuildResult(_serialization.Model): """The build result triggered by a build. :ivar id: The unique build id of this build result. @@ -5717,24 +5341,19 @@ class TriggeredBuildResult(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The unique build id of this build result. :paramtype id: str """ - super(TriggeredBuildResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class ValidationMessages(msrest.serialization.Model): +class ValidationMessages(_serialization.Model): """Validate messages of the configuration service git repositories. :ivar name: The name of the configuration service git repository. @@ -5744,23 +5363,17 @@ class ValidationMessages(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'messages': {'key': 'messages', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - messages: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs): """ :keyword name: The name of the configuration service git repository. :paramtype name: str :keyword messages: Detailed validation messages. :paramtype messages: list[str] """ - super(ValidationMessages, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.messages = messages diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/__init__.py index 152a0c3a0764..0567c6e67b60 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/__init__.py @@ -24,22 +24,28 @@ from ._runtime_versions_operations import RuntimeVersionsOperations from ._skus_operations import SkusOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'ConfigurationServicesOperations', - 'ServiceRegistriesOperations', - 'BuildServiceOperations', - 'BuildpackBindingOperations', - 'BuildServiceBuilderOperations', - 'BuildServiceAgentPoolOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', + "ServicesOperations", + "ConfigServersOperations", + "ConfigurationServicesOperations", + "ServiceRegistriesOperations", + "BuildServiceOperations", + "BuildpackBindingOperations", + "BuildServiceBuilderOperations", + "BuildServiceAgentPoolOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_apps_operations.py index 8e2678df7da5..09d1e4f9a8a7 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_apps_operations.py @@ -6,387 +6,334 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, sync_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 sync_status is not None: - _query_parameters['syncStatus'] = _SERIALIZER.query("sync_status", sync_status, 'str') + _params["syncStatus"] = _SERIALIZER.query("sync_status", sync_status, "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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str +def build_list_request(resource_group_name: str, service_name: str, 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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_resource_upload_url_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_set_active_deployments_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_set_active_deployments_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_validate_domain_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class AppsOperations(object): - """AppsOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`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 get( @@ -396,102 +343,121 @@ def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(app_resource, 'AppResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - 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(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -499,21 +465,98 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_04_01.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -521,20 +564,24 @@ def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_04_01.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_04_01.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -546,84 +593,89 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either AppResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -633,25 +685,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -663,83 +710,101 @@ 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-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(app_resource, 'AppResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -747,18 +812,95 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_04_01.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -766,20 +908,24 @@ def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_04_01.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_04_01.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -791,104 +937,113 @@ def begin_update( :return: An instance of LROPoller that returns either AppResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AppResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -902,10 +1057,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 @@ -915,112 +1068,125 @@ 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.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore def _set_active_deployments_initial( self, resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(active_deployment_collection, 'ActiveDeploymentCollection') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_set_active_deployments_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(active_deployment_collection, (IO, bytes)): + _content = active_deployment_collection + else: + _json = self._serialize.body(active_deployment_collection, "ActiveDeploymentCollection") + + request = build_set_active_deployments_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._set_active_deployments_initial.metadata['url'], + content=_content, + template_url=self._set_active_deployments_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]: @@ -1028,18 +1194,96 @@ def _set_active_deployments_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _set_active_deployments_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + _set_active_deployments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + + @overload + def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: _models.ActiveDeploymentCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_04_01.models.ActiveDeploymentCollection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_set_active_deployments( @@ -1047,21 +1291,25 @@ def begin_set_active_deployments( resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Set existing Deployment under the app as active. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param active_deployment_collection: A list of Deployment name to be active. + :param active_deployment_collection: A list of Deployment name to be active. Is either a model + type or a IO type. Required. :type active_deployment_collection: - ~azure.mgmt.appplatform.v2022_04_01.models.ActiveDeploymentCollection + ~azure.mgmt.appplatform.v2022_04_01.models.ActiveDeploymentCollection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1073,51 +1321,116 @@ def begin_set_active_deployments( :return: An instance of LROPoller that returns either AppResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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._set_active_deployments_initial( + raw_result = self._set_active_deployments_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, active_deployment_collection=active_deployment_collection, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_set_active_deployments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + begin_set_active_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def validate_domain( @@ -1125,66 +1438,84 @@ def validate_domain( resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: Union[_models.CustomDomainValidatePayload, IO], **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainValidatePayload + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_bindings_operations.py index d8a5486c7643..e52b318c97cd 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_bindings_operations.py @@ -6,330 +6,298 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class BindingsOperations(object): - """BindingsOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +305,53 @@ def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(binding_resource, 'BindingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - 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(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -377,21 +359,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +467,26 @@ def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +499,19 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +519,71 @@ def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -518,28 +593,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -551,46 +620,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _update_initial( self, @@ -598,39 +671,53 @@ def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(binding_resource, 'BindingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -638,18 +725,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +830,26 @@ def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +862,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +882,100 @@ def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +989,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 @@ -816,8 +1000,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_build_service_agent_pool_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_build_service_agent_pool_operations.py index 46ed30daead5..95207130a495 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_build_service_agent_pool_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_build_service_agent_pool_operations.py @@ -6,233 +6,238 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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, service_name: str, build_service_name: str, agent_pool_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_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_update_put_request_initial( - subscription_id: str, +def build_update_put_request( resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_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 - ) - -class BuildServiceAgentPoolOperations(object): - """BuildServiceAgentPoolOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["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) + + +class BuildServiceAgentPoolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`build_service_agent_pool` 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, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildServiceAgentPoolResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.BuildServiceAgentPoolResource"]: """List build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceAgentPoolResourceCollection or the - result of cls(response) + :return: An iterator like instance of either BuildServiceAgentPoolResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -246,10 +251,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 @@ -259,78 +262,76 @@ 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - agent_pool_name: str, - **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": + self, resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: """Get build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildServiceAgentPoolResource, or the result of cls(response) + :return: BuildServiceAgentPoolResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore def _update_put_initial( self, @@ -338,39 +339,53 @@ def _update_put_initial( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] + ) -> _models.BuildServiceAgentPoolResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(agent_pool_resource, 'BuildServiceAgentPoolResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(agent_pool_resource, (IO, bytes)): + _content = agent_pool_resource + else: + _json = self._serialize.body(agent_pool_resource, "BuildServiceAgentPoolResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -378,18 +393,104 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: _models.BuildServiceAgentPoolResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( @@ -398,23 +499,27 @@ def begin_update_put( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> LROPoller["_models.BuildServiceAgentPoolResource"]: + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: """Create or update build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str - :param agent_pool_resource: Parameters for the update operation. + :param agent_pool_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type agent_pool_resource: - ~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource + ~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -427,19 +532,19 @@ def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceAgentPoolResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, @@ -447,29 +552,32 @@ def begin_update_put( agent_pool_resource=agent_pool_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_build_service_builder_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_build_service_builder_operations.py index 47acb0bb488f..b00e9392a576 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_build_service_builder_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_build_service_builder_operations.py @@ -6,282 +6,277 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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, +def build_delete_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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 BuildServiceBuilderOperations(object): - """BuildServiceBuilderOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BuildServiceBuilderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`build_service_builder` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> "_models.BuilderResource": + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.BuilderResource: """Get a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuilderResource, or the result of cls(response) + :return: BuilderResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore def _create_or_update_initial( self, @@ -289,39 +284,53 @@ def _create_or_update_initial( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> "_models.BuilderResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] + ) -> _models.BuilderResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(builder_resource, 'BuilderResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] - 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(builder_resource, (IO, bytes)): + _content = builder_resource + else: + _json = self._serialize.body(builder_resource, "BuilderResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -329,18 +338,103 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: _models.BuilderResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -349,22 +443,26 @@ def begin_create_or_update( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> LROPoller["_models.BuilderResource"]: + ) -> LROPoller[_models.BuilderResource]: """Create or update a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param builder_resource: The target builder for the create or update operation. - :type builder_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource + :param builder_resource: The target builder for the create or update operation. Is either a + model type or a IO type. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -377,19 +475,19 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -397,67 +495,71 @@ def begin_create_or_update( builder_resource=builder_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, build_service_name: str, builder_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -467,28 +569,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_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. @@ -500,104 +596,115 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuilderResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.BuilderResource"]: """List KPack builders result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuilderResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BuilderResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuilderResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -611,10 +718,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 @@ -624,8 +729,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_build_service_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_build_service_operations.py index 7b06e6035584..7224717cfa86 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_build_service_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_build_service_operations.py @@ -6,618 +6,584 @@ # Code generated 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 +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_build_services_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_build_service_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_builds_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_build_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_build_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_list_build_results_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_build_result_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, build_result_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), - "buildResultName": _SERIALIZER.url("build_result_name", build_result_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_name, "str"), + "buildResultName": _SERIALIZER.url("build_result_name", build_result_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_build_result_log_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, build_result_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), - "buildResultName": _SERIALIZER.url("build_result_name", build_result_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_name, "str"), + "buildResultName": _SERIALIZER.url("build_result_name", build_result_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_get_resource_upload_url_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_list_supported_buildpacks_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_supported_buildpack_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildpackName": _SERIALIZER.url("buildpack_name", buildpack_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildpackName": _SERIALIZER.url("buildpack_name", buildpack_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_supported_stacks_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_supported_stack_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "stackName": _SERIALIZER.url("stack_name", stack_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "stackName": _SERIALIZER.url("stack_name", stack_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 BuildServiceOperations(object): - """BuildServiceOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BuildServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`build_service` 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_build_services( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildServiceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.BuildService"]: """List build services resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceCollection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildServiceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BuildService or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildService] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_services_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_services.metadata['url'], + template_url=self.list_build_services.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_build_services_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -631,10 +597,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 @@ -644,131 +608,137 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_build_services.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore + list_build_services.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore @distributed_trace def get_build_service( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.BuildService": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.BuildService: """Get a build service resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildService, or the result of cls(response) + :return: BuildService or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.BuildService - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildService"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildService] - request = build_get_build_service_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_service.metadata['url'], + template_url=self.get_build_service.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildService', pipeline_response) + deserialized = self._deserialize("BuildService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore - + get_build_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore @distributed_trace def list_builds( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.Build"]: """List KPack builds. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildCollection or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Build or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_builds_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_builds.metadata['url'], + template_url=self.list_builds.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_builds_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -782,10 +752,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 @@ -795,78 +763,144 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_builds.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore + list_builds.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore @distributed_trace def get_build( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> "_models.Build": + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> _models.Build: """Get a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - request = build_get_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build.metadata['url'], + template_url=self.get_build.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + get_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + @overload + def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: _models.Build, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: ~azure.mgmt.appplatform.v2022_04_01.models.Build + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update_build( @@ -875,57 +909,75 @@ def create_or_update_build( service_name: str, build_service_name: str, build_name: str, - build: "_models.Build", + build: Union[_models.Build, IO], **kwargs: Any - ) -> "_models.Build": + ) -> _models.Build: """Create or update a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build: Parameters for the create or update operation. - :type build: ~azure.mgmt.appplatform.v2022_04_01.models.Build + :param build: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type build: ~azure.mgmt.appplatform.v2022_04_01.models.Build or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - _json = self._serialize.body(build, 'Build') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build, (IO, bytes)): + _content = build + else: + _json = self._serialize.body(build, "Build") request = build_create_or_update_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_build.metadata['url'], + content=_content, + template_url=self.create_or_update_build.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]: @@ -933,81 +985,84 @@ def create_or_update_build( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore - + create_or_update_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore @distributed_trace def list_build_results( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildResultCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> Iterable["_models.BuildResult"]: """List KPack build results. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildResultCollection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildResultCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BuildResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_results_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_results.metadata['url'], + template_url=self.list_build_results.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_build_results_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - build_name=build_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1021,10 +1076,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 @@ -1034,11 +1087,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_build_results.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore + list_build_results.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore @distributed_trace def get_build_result( @@ -1049,67 +1100,72 @@ def get_build_result( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResult": + ) -> _models.BuildResult: """Get a KPack build result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResult, or the result of cls(response) + :return: BuildResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.BuildResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResult] - request = build_get_build_result_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result.metadata['url'], + template_url=self.get_build_result.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResult', pipeline_response) + deserialized = self._deserialize("BuildResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore - + get_build_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore @distributed_trace def get_build_result_log( @@ -1120,387 +1176,395 @@ def get_build_result_log( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResultLog": + ) -> _models.BuildResultLog: """Get a KPack build result log download URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResultLog, or the result of cls(response) + :return: BuildResultLog or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.BuildResultLog - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultLog"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultLog] - request = build_get_build_result_log_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result_log.metadata['url'], + template_url=self.get_build_result_log.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResultLog', pipeline_response) + deserialized = self._deserialize("BuildResultLog", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result_log.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore - + get_build_result_log.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore @distributed_trace def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for build service, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore @distributed_trace def list_supported_buildpacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedBuildpacksCollection: """Get all supported buildpacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpacksCollection, or the result of cls(response) + :return: SupportedBuildpacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.SupportedBuildpacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpacksCollection] - request = build_list_supported_buildpacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_buildpacks.metadata['url'], + template_url=self.list_supported_buildpacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedBuildpacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_buildpacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore - + list_supported_buildpacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore @distributed_trace def get_supported_buildpack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - buildpack_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, **kwargs: Any + ) -> _models.SupportedBuildpackResource: """Get the supported buildpack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param buildpack_name: The name of the buildpack resource. + :param buildpack_name: The name of the buildpack resource. Required. :type buildpack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpackResource, or the result of cls(response) + :return: SupportedBuildpackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.SupportedBuildpackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpackResource] - request = build_get_supported_buildpack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, buildpack_name=buildpack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_buildpack.metadata['url'], + template_url=self.get_supported_buildpack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpackResource', pipeline_response) + deserialized = self._deserialize("SupportedBuildpackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_buildpack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore - + get_supported_buildpack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore @distributed_trace def list_supported_stacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedStacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedStacksCollection: """Get all supported stacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStacksCollection, or the result of cls(response) + :return: SupportedStacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.SupportedStacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStacksCollection] - request = build_list_supported_stacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_stacks.metadata['url'], + template_url=self.list_supported_stacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedStacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_stacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore - + list_supported_stacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore @distributed_trace def get_supported_stack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - stack_name: str, - **kwargs: Any - ) -> "_models.SupportedStackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, **kwargs: Any + ) -> _models.SupportedStackResource: """Get the supported stack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param stack_name: The name of the stack resource. + :param stack_name: The name of the stack resource. Required. :type stack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStackResource, or the result of cls(response) + :return: SupportedStackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.SupportedStackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStackResource] - request = build_get_supported_stack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, stack_name=stack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_stack.metadata['url'], + template_url=self.get_supported_stack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStackResource', pipeline_response) + deserialized = self._deserialize("SupportedStackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_stack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore - + get_supported_stack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_buildpack_binding_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_buildpack_binding_operations.py index e6e495b96e97..3e3f6db5d17e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_buildpack_binding_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_buildpack_binding_operations.py @@ -6,223 +6,222 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, buildpack_binding_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), - "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, buildpack_binding_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), - "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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, +def build_delete_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, buildpack_binding_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), - "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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 BuildpackBindingOperations(object): - """BuildpackBindingOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BuildpackBindingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`buildpack_binding` 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( @@ -233,67 +232,72 @@ def get( builder_name: str, buildpack_binding_name: str, **kwargs: Any - ) -> "_models.BuildpackBindingResource": + ) -> _models.BuildpackBindingResource: """Get a buildpack binding by name. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildpackBindingResource, or the result of cls(response) + :return: BuildpackBindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore def _create_or_update_initial( self, @@ -302,40 +306,54 @@ def _create_or_update_initial( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: Union[_models.BuildpackBindingResource, IO], **kwargs: Any - ) -> "_models.BuildpackBindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] + ) -> _models.BuildpackBindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(buildpack_binding, 'BuildpackBindingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] - 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(buildpack_binding, (IO, bytes)): + _content = buildpack_binding + else: + _json = self._serialize.body(buildpack_binding, "BuildpackBindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -343,20 +361,19 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, @@ -364,24 +381,30 @@ def begin_create_or_update( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: _models.BuildpackBindingResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.BuildpackBindingResource"]: + ) -> LROPoller[_models.BuildpackBindingResource]: """Create or update a buildpack binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. :type buildpack_binding: ~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -394,19 +417,112 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] - 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, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. Is + either a model type or a IO type. Required. + :type buildpack_binding: ~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResource] + :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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -415,32 +531,35 @@ def begin_create_or_update( buildpack_binding=buildpack_binding, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -451,33 +570,39 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements buildpack_binding_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -487,11 +612,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, service_name: str, @@ -503,15 +627,15 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Operation to delete a Buildpack Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_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. @@ -523,110 +647,120 @@ 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-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildpackBindingResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> Iterable["_models.BuildpackBindingResource"]: """Handles requests to list all buildpack bindings in a builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildpackBindingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either BuildpackBindingResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, - service_name=service_name, - build_service_name=build_service_name, - builder_name=builder_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -640,10 +774,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 @@ -653,8 +785,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_certificates_operations.py index dcc60dcc7f5d..354c426e8cd4 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_certificates_operations.py @@ -6,308 +6,305 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - 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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", 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.appplatform.v2022_04_01.AppPlatformManagementClient`'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 get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_resource, 'CertificateResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - 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(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -315,21 +312,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -337,20 +413,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> LROPoller["_models.CertificateResource"]: + ) -> LROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. - :type certificate_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type certificate_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -363,84 +444,89 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -450,25 +536,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -480,98 +561,111 @@ 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-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -585,10 +679,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 @@ -598,8 +690,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_config_servers_operations.py index 6c8346d206a4..6ec11d8376b0 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_config_servers_operations.py @@ -6,311 +6,299 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_validate_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/configServers/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ConfigServersOperations(object): - """ConfigServersOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -318,36 +306,114 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -360,86 +426,103 @@ def begin_update_put( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -447,36 +530,114 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -489,86 +650,103 @@ def begin_update_patch( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(config_server_settings, 'ConfigServerSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -576,36 +754,114 @@ def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerSettings + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -618,47 +874,52 @@ def begin_validate( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_configuration_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_configuration_services_operations.py index 4445a51fd115..6a49d2a05a82 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_configuration_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_configuration_services_operations.py @@ -6,354 +6,340 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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, - service_name: str, - configuration_service_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, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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, - service_name: str, - configuration_service_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, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - configuration_service_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_validate_request( + resource_group_name: str, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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 ConfigurationServicesOperations(object): - """ConfigurationServicesOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["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 ConfigurationServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`configuration_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any - ) -> "_models.ConfigurationServiceResource": + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> _models.ConfigurationServiceResource: """Get the Application Configuration Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigurationServiceResource, or the result of cls(response) + :return: ConfigurationServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] + ) -> _models.ConfigurationServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(configuration_service_resource, 'ConfigurationServiceResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] - 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(configuration_service_resource, (IO, bytes)): + _content = configuration_service_resource + else: + _json = self._serialize.body(configuration_service_resource, "ConfigurationServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -361,18 +347,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: _models.ConfigurationServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -380,22 +448,26 @@ def begin_create_or_update( resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigurationServiceResource"]: + ) -> LROPoller[_models.ConfigurationServiceResource]: """Create the default Application Configuration Service or update the existing Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param configuration_service_resource: Parameters for the update operation. + :param configuration_service_resource: Parameters for the update operation. Is either a model + type or a IO type. Required. :type configuration_service_resource: - ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource + ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -408,84 +480,89 @@ def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + 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, service_name=service_name, configuration_service_name=configuration_service_name, configuration_service_resource=configuration_service_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, configuration_service_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -495,25 +572,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any ) -> LROPoller[None]: """Disable the default Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_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. @@ -525,98 +597,112 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, configuration_service_name=configuration_service_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.ConfigurationServiceResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.ConfigurationServiceResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationServiceResourceCollection or the - result of cls(response) + :return: An iterator like instance of either ConfigurationServiceResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -630,10 +716,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 @@ -643,49 +727,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.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore def _validate_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] + ) -> _models.ConfigurationServiceSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(settings, 'ConfigurationServiceSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(settings, (IO, bytes)): + _content = settings + else: + _json = self._serialize.body(settings, "ConfigurationServiceSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -693,18 +789,97 @@ def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: _models.ConfigurationServiceSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_validate( @@ -712,20 +887,24 @@ def begin_validate( resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigurationServiceSettingsValidateResult"]: + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: """Check if the Application Configuration Service settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param settings: Application Configuration Service settings to be validated. - :type settings: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceSettings + :param settings: Application Configuration Service settings to be validated. Is either a model + type or a IO type. Required. + :type settings: ~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -738,48 +917,53 @@ def begin_validate( ConfigurationServiceSettingsValidateResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ConfigurationServiceSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + 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._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, settings=settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_custom_domains_operations.py index 411a7af4d430..18fa119c2d45 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_custom_domains_operations.py @@ -6,330 +6,298 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class CustomDomainsOperations(object): - """CustomDomainsOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +305,53 @@ def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(domain_resource, 'CustomDomainResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - 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(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -377,21 +359,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +467,26 @@ def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. - :type domain_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +499,19 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +519,71 @@ def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -518,28 +593,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -551,46 +620,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _update_initial( self, @@ -598,39 +671,53 @@ def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(domain_resource, 'CustomDomainResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -638,18 +725,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +830,26 @@ def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. - :type domain_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +862,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +882,101 @@ def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +990,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 @@ -816,8 +1001,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_deployments_operations.py index d9b0bc5e624e..1f1f3ee2c42d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_deployments_operations.py @@ -6,678 +6,639 @@ # Code generated 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, List, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_delete_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_for_cluster_request( - subscription_id: str, resource_group_name: str, service_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_start_request_initial( - subscription_id: str, +def build_start_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_stop_request_initial( - subscription_id: str, +def build_stop_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request_initial( - subscription_id: str, +def build_restart_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_get_log_file_url_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_generate_heap_dump_request_initial( - subscription_id: str, +def build_generate_heap_dump_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_generate_thread_dump_request_initial( - subscription_id: str, +def build_generate_thread_dump_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_start_jfr_request_initial( - subscription_id: str, +def build_start_jfr_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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 DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["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 DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( self, @@ -685,39 +646,53 @@ def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(deployment_resource, 'DeploymentResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - 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(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -725,21 +700,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -748,22 +808,26 @@ def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. - :type deployment_resource: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -776,19 +840,19 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -796,67 +860,71 @@ def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -866,28 +934,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -899,46 +961,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _update_initial( self, @@ -946,39 +1012,53 @@ def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(deployment_resource, 'DeploymentResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -986,18 +1066,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -1006,22 +1171,26 @@ def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. - :type deployment_resource: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type deployment_resource: ~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1034,19 +1203,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -1054,32 +1223,35 @@ def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -1089,60 +1261,70 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + ) -> Iterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1156,10 +1338,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 @@ -1169,69 +1349,74 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1245,10 +1430,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 @@ -1258,46 +1441,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1307,28 +1489,22 @@ def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1340,81 +1516,86 @@ def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1424,28 +1605,22 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1457,81 +1632,86 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -1541,28 +1721,22 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace - def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1574,98 +1748,103 @@ def begin_restart( # 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-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1674,15 +1853,14 @@ def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1690,39 +1868,53 @@ def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statemen service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_generate_heap_dump_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_heap_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_heap_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_heap_dump_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]: @@ -1732,32 +1924,118 @@ def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _generate_heap_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + _generate_heap_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + @overload + def begin_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_heap_dump( # pylint: disable=inconsistent-return-statements + def begin_generate_heap_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Generate Heap Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. - :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1768,19 +2046,19 @@ def begin_generate_heap_dump( # 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[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", "2022-04-01")) # type: Literal["2022-04-01"] + 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._generate_heap_dump_initial( + raw_result = self._generate_heap_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1788,29 +2066,33 @@ def begin_generate_heap_dump( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **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_generate_heap_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + begin_generate_heap_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1818,39 +2100,53 @@ def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statem service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_generate_thread_dump_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_thread_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_thread_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_thread_dump_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]: @@ -1860,32 +2156,118 @@ def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _generate_thread_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + _generate_thread_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + @overload + def begin_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_thread_dump( # pylint: disable=inconsistent-return-statements + def begin_generate_thread_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Generate Thread Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. - :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1896,19 +2278,19 @@ def begin_generate_thread_dump( # pylint: disable=inconsistent-return-statement 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[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", "2022-04-01")) # type: Literal["2022-04-01"] + 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._generate_thread_dump_initial( + raw_result = self._generate_thread_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1916,29 +2298,33 @@ def begin_generate_thread_dump( # pylint: disable=inconsistent-return-statement diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **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_generate_thread_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + begin_generate_thread_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore def _start_jfr_initial( # pylint: disable=inconsistent-return-statements self, @@ -1946,39 +2332,53 @@ def _start_jfr_initial( # pylint: disable=inconsistent-return-statements service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_start_jfr_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_start_jfr_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._start_jfr_initial.metadata['url'], + content=_content, + template_url=self._start_jfr_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]: @@ -1988,32 +2388,118 @@ def _start_jfr_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_jfr_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + _start_jfr_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + + @overload + def begin_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_start_jfr( # pylint: disable=inconsistent-return-statements + def begin_start_jfr( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Start JFR. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. - :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.DiagnosticParameters or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2024,19 +2510,19 @@ def begin_start_jfr( # 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[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", "2022-04-01")) # type: Literal["2022-04-01"] + 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._start_jfr_initial( + raw_result = self._start_jfr_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -2044,26 +2530,30 @@ def begin_start_jfr( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **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_start_jfr.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + begin_start_jfr.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_monitoring_settings_operations.py index ed3089493c21..f9f0a343c537 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_monitoring_settings_operations.py @@ -6,267 +6,265 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 MonitoringSettingsOperations(object): - """MonitoringSettingsOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -274,37 +272,115 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -317,86 +393,103 @@ def begin_update_put( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -404,37 +497,115 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation 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,47 +618,50 @@ def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_operations.py index 8aa9a994c276..6c3fed289e52 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_operations.py @@ -6,111 +6,130 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="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.appplatform.v2022_04_01.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,10 +143,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 +154,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_runtime_versions_operations.py index 4295dc5119c3..856de791e9b8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_runtime_versions_operations.py @@ -6,117 +6,124 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from 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 -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_runtime_versions_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - accept = "application/json" +def build_list_runtime_versions_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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/runtimeVersions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 RuntimeVersionsOperations(object): - """RuntimeVersionsOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_service_registries_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_service_registries_operations.py index 6f1001b7b9cb..505a9d9e0eb2 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_service_registries_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_service_registries_operations.py @@ -6,294 +6,285 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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, - service_name: str, - service_registry_name: str, - **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, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + _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, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ServiceRegistriesOperations(object): - """ServiceRegistriesOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServiceRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`service_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: """Get the Service Registry and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceRegistryResource, or the result of cls(response) + :return: ServiceRegistryResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.ServiceRegistryResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._create_or_update_initial.metadata['url'], + 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]: @@ -301,35 +292,30 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> LROPoller["_models.ServiceRegistryResource"]: + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> LROPoller[_models.ServiceRegistryResource]: """Create the default Service Registry or update the existing Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -343,81 +329,86 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ServiceRegistryResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] - 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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: @@ -427,25 +418,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> LROPoller[None]: """Disable the default Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -457,98 +443,112 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.ServiceRegistryResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.ServiceRegistryResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceRegistryResourceCollection or the result of + :return: An iterator like instance of either ServiceRegistryResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ServiceRegistryResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ServiceRegistryResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -562,10 +562,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 @@ -575,8 +573,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_services_operations.py index 99a8f74e7b2f..10c6adcc76e3 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_services_operations.py @@ -6,564 +6,504 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_test_keys_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_regenerate_test_key_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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.AppPlatform/Spring/{serviceName}/regenerateTestKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_disable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_enable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-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-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_check_name_availability_request( - subscription_id: str, - location: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_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-04-01")) # type: Literal["2022-04-01"] + 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}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "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 - ) - - -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 ServicesOperations(object): - """ServicesOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(resource, 'ServiceResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - 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(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -571,39 +511,43 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -616,81 +560,156 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] + :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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_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-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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]: @@ -700,22 +719,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -727,80 +740,94 @@ 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-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(resource, 'ServiceResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -808,36 +835,40 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -850,220 +881,369 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] + :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", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_04_01.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2022_04_01.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2022_04_01.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -1073,170 +1253,239 @@ def disable_test_endpoint( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace - def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def enable_test_endpoint(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - - @distributed_trace + @overload def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2022_04_01.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_04_01.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_04_01.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(availability_parameters, 'NameAvailabilityParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1250,10 +1499,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 @@ -1263,58 +1510,66 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1328,10 +1583,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 @@ -1341,8 +1594,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_skus_operations.py index 4b65de70e557..b81c875f8a1a 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_04_01/operations/_skus_operations.py @@ -6,120 +6,135 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: Literal["2022-04-01"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 SkusOperations(object): - """SkusOperations 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.appplatform.v2022_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_04_01.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourceSku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_04_01.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-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", "2022-04-01")) # type: Literal["2022-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -133,10 +148,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 @@ -146,8 +159,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/__init__.py index 41ec6d71ff7f..a6bfaa2de14d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_app_platform_management_client.py index 68cee389f377..d2789f09047e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_app_platform_management_client.py @@ -9,20 +9,44 @@ 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 .._serialization import Deserializer, Serializer from ._configuration import AppPlatformManagementClientConfiguration -from .operations import ApiPortalCustomDomainsOperations, ApiPortalsOperations, AppsOperations, BindingsOperations, BuildServiceAgentPoolOperations, BuildServiceBuilderOperations, BuildServiceOperations, BuildpackBindingOperations, CertificatesOperations, ConfigServersOperations, ConfigurationServicesOperations, CustomDomainsOperations, DeploymentsOperations, GatewayCustomDomainsOperations, GatewayRouteConfigsOperations, GatewaysOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServiceRegistriesOperations, ServicesOperations, SkusOperations, StoragesOperations +from .operations import ( + ApiPortalCustomDomainsOperations, + ApiPortalsOperations, + AppsOperations, + BindingsOperations, + BuildServiceAgentPoolOperations, + BuildServiceBuilderOperations, + BuildServiceOperations, + BuildpackBindingOperations, + CertificatesOperations, + ConfigServersOperations, + ConfigurationServicesOperations, + CustomDomainsOperations, + DeploymentsOperations, + GatewayCustomDomainsOperations, + GatewayRouteConfigsOperations, + GatewaysOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServiceRegistriesOperations, + ServicesOperations, + SkusOperations, + StoragesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Apps. :ivar services: ServicesOperations operations @@ -87,10 +111,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib :ivar api_portal_custom_domains: ApiPortalCustomDomainsOperations operations :vartype api_portal_custom_domains: azure.mgmt.appplatform.v2022_05_01_preview.operations.ApiPortalCustomDomainsOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -108,7 +132,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -117,13 +143,25 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.configuration_services = ConfigurationServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.service_registries = ServiceRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_services = ConfigurationServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_registries = ServiceRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.build_service = BuildServiceOperations(self._client, self._config, self._serialize, self._deserialize) - self.buildpack_binding = BuildpackBindingOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_builder = BuildServiceBuilderOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_agent_pool = BuildServiceAgentPoolOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.buildpack_binding = BuildpackBindingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_builder = BuildServiceBuilderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_agent_pool = BuildServiceAgentPoolOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.storages = StoragesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -131,20 +169,23 @@ def __init__( self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.gateways = GatewaysOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_route_configs = GatewayRouteConfigsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_custom_domains = GatewayCustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_route_configs = GatewayRouteConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gateway_custom_domains = GatewayCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.api_portals = ApiPortalsOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_portal_custom_domains = ApiPortalCustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.api_portal_custom_domains = ApiPortalCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -153,7 +194,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_configuration.py index e8e7fc80c5d7..2d7c4ba2d8d2 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + api_version = kwargs.pop("api_version", "2022-05-01-preview") # type: Literal["2022-05-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_metadata.json b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_metadata.json index d33fd3659075..fbb81e3a604c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_metadata.json +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"]}, \"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\": [\"AppPlatformManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -121,4 +121,4 @@ "api_portals": "ApiPortalsOperations", "api_portal_custom_domains": "ApiPortalCustomDomainsOperations" } -} \ No newline at end of file +} diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_vendor.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_vendor.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_version.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_version.py index e7ffc58c0429..92453d8691d9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_version.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.1.0" +VERSION = "6.1.0" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/__init__.py index 44ce4a5043f8..398c48287ad8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._app_platform_management_client import AppPlatformManagementClient -__all__ = ['AppPlatformManagementClient'] -# `._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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/_app_platform_management_client.py index 9df90c909287..ff981f839701 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/_app_platform_management_client.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/_app_platform_management_client.py @@ -9,20 +9,44 @@ 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 AppPlatformManagementClientConfiguration -from .operations import ApiPortalCustomDomainsOperations, ApiPortalsOperations, AppsOperations, BindingsOperations, BuildServiceAgentPoolOperations, BuildServiceBuilderOperations, BuildServiceOperations, BuildpackBindingOperations, CertificatesOperations, ConfigServersOperations, ConfigurationServicesOperations, CustomDomainsOperations, DeploymentsOperations, GatewayCustomDomainsOperations, GatewayRouteConfigsOperations, GatewaysOperations, MonitoringSettingsOperations, Operations, RuntimeVersionsOperations, ServiceRegistriesOperations, ServicesOperations, SkusOperations, StoragesOperations +from .operations import ( + ApiPortalCustomDomainsOperations, + ApiPortalsOperations, + AppsOperations, + BindingsOperations, + BuildServiceAgentPoolOperations, + BuildServiceBuilderOperations, + BuildServiceOperations, + BuildpackBindingOperations, + CertificatesOperations, + ConfigServersOperations, + ConfigurationServicesOperations, + CustomDomainsOperations, + DeploymentsOperations, + GatewayCustomDomainsOperations, + GatewayRouteConfigsOperations, + GatewaysOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServiceRegistriesOperations, + ServicesOperations, + SkusOperations, + StoragesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AppPlatformManagementClient: # pylint: disable=too-many-instance-attributes + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Spring Apps. :ivar services: ServicesOperations operations @@ -87,10 +111,10 @@ class AppPlatformManagementClient: # pylint: disable=too-many-instance-attrib :ivar api_portal_custom_domains: ApiPortalCustomDomainsOperations operations :vartype api_portal_custom_domains: azure.mgmt.appplatform.v2022_05_01_preview.aio.operations.ApiPortalCustomDomainsOperations - :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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -108,7 +132,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AppPlatformManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AppPlatformManagementClientConfiguration( + 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)} @@ -117,13 +143,25 @@ def __init__( self._serialize.client_side_validation = False self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.configuration_services = ConfigurationServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.service_registries = ServiceRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_services = ConfigurationServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_registries = ServiceRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.build_service = BuildServiceOperations(self._client, self._config, self._serialize, self._deserialize) - self.buildpack_binding = BuildpackBindingOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_builder = BuildServiceBuilderOperations(self._client, self._config, self._serialize, self._deserialize) - self.build_service_agent_pool = BuildServiceAgentPoolOperations(self._client, self._config, self._serialize, self._deserialize) - self.monitoring_settings = MonitoringSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.buildpack_binding = BuildpackBindingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_builder = BuildServiceBuilderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_agent_pool = BuildServiceAgentPoolOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) self.storages = StoragesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -131,20 +169,23 @@ def __init__( self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.runtime_versions = RuntimeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.gateways = GatewaysOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_route_configs = GatewayRouteConfigsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_custom_domains = GatewayCustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_route_configs = GatewayRouteConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gateway_custom_domains = GatewayCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.api_portals = ApiPortalsOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_portal_custom_domains = ApiPortalCustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.api_portal_custom_domains = ApiPortalCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -153,7 +194,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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/_configuration.py index ecc6689ee8bc..8ff3957256c9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/_configuration.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class AppPlatformManagementClientConfiguration(Configuration): # pylint: disabl 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: Gets subscription ID which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + api_version = kwargs.pop("api_version", "2022-05-01-preview") # type: Literal["2022-05-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,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-appplatform/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".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/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/_patch.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/__init__.py index 0da100b4246c..57694a8d82f6 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/__init__.py @@ -30,28 +30,34 @@ from ._api_portals_operations import ApiPortalsOperations from ._api_portal_custom_domains_operations import ApiPortalCustomDomainsOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'ConfigurationServicesOperations', - 'ServiceRegistriesOperations', - 'BuildServiceOperations', - 'BuildpackBindingOperations', - 'BuildServiceBuilderOperations', - 'BuildServiceAgentPoolOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'StoragesOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', - 'GatewaysOperations', - 'GatewayRouteConfigsOperations', - 'GatewayCustomDomainsOperations', - 'ApiPortalsOperations', - 'ApiPortalCustomDomainsOperations', + "ServicesOperations", + "ConfigServersOperations", + "ConfigurationServicesOperations", + "ServiceRegistriesOperations", + "BuildServiceOperations", + "BuildpackBindingOperations", + "BuildServiceBuilderOperations", + "BuildServiceAgentPoolOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "StoragesOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", + "GatewaysOperations", + "GatewayRouteConfigsOperations", + "GatewayCustomDomainsOperations", + "ApiPortalsOperations", + "ApiPortalCustomDomainsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_api_portal_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_api_portal_custom_domains_operations.py index bc1dd276e635..eb3e6c6e661b 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_api_portal_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_api_portal_custom_domains_operations.py @@ -6,113 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_portal_custom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._api_portal_custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiPortalCustomDomainsOperations: - """ApiPortalCustomDomainsOperations 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 ApiPortalCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`api_portal_custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.ApiPortalCustomDomainResource": + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any + ) -> _models.ApiPortalCustomDomainResource: """Get the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiPortalCustomDomainResource, or the result of cls(response) + :return: ApiPortalCustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +140,55 @@ async def _create_or_update_initial( service_name: str, api_portal_name: str, domain_name: str, - api_portal_custom_domain_resource: "_models.ApiPortalCustomDomainResource", + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], **kwargs: Any - ) -> "_models.ApiPortalCustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] + ) -> _models.ApiPortalCustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(api_portal_custom_domain_resource, 'ApiPortalCustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_custom_domain_resource, (IO, bytes)): + _content = api_portal_custom_domain_resource + else: + _json = self._serialize.body(api_portal_custom_domain_resource, "ApiPortalCustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: @@ -160,18 +196,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: _models.ApiPortalCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,24 +304,27 @@ async def begin_create_or_update( service_name: str, api_portal_name: str, domain_name: str, - api_portal_custom_domain_resource: "_models.ApiPortalCustomDomainResource", + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ApiPortalCustomDomainResource"]: + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: """Create or update the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_name: str :param api_portal_custom_domain_resource: The API portal custom domain for the create or update - operation. + operation. Is either a model type or a IO type. Required. :type api_portal_custom_domain_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -210,19 +337,21 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + 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, service_name=service_name, api_portal_name=api_portal_name, @@ -230,67 +359,73 @@ async def begin_create_or_update( api_portal_custom_domain_resource=api_portal_custom_domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: @@ -300,28 +435,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_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. @@ -333,104 +462,120 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ApiPortalCustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApiPortalCustomDomainResource"]: """Handle requests to list all API portal custom domains. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiPortalCustomDomainResourceCollection or the - result of cls(response) + :return: An iterator like instance of either ApiPortalCustomDomainResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, api_portal_name=api_portal_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, - service_name=service_name, - api_portal_name=api_portal_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -444,10 +589,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 @@ -457,8 +600,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_api_portals_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_api_portals_operations.py index 2f49464fc059..932fb5909679 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_api_portals_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_api_portals_operations.py @@ -6,147 +6,185 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_portals_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_validate_domain_request -T = TypeVar('T') +from ...operations._api_portals_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiPortalsOperations: - """ApiPortalsOperations 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 ApiPortalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`api_portals` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any - ) -> "_models.ApiPortalResource": + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> _models.ApiPortalResource: """Get the API portal and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiPortalResource, or the result of cls(response) + :return: ApiPortalResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, api_portal_name: str, - api_portal_resource: "_models.ApiPortalResource", + api_portal_resource: Union[_models.ApiPortalResource, IO], **kwargs: Any - ) -> "_models.ApiPortalResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] + ) -> _models.ApiPortalResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(api_portal_resource, 'ApiPortalResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_resource, (IO, bytes)): + _content = api_portal_resource + else: + _json = self._serialize.body(api_portal_resource, "ApiPortalResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: @@ -154,18 +192,97 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: _models.ApiPortalResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -173,20 +290,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, api_portal_name: str, - api_portal_resource: "_models.ApiPortalResource", + api_portal_resource: Union[_models.ApiPortalResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ApiPortalResource"]: + ) -> AsyncLROPoller[_models.ApiPortalResource]: """Create the default API portal or update the existing API portal. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param api_portal_resource: The API portal for the create or update operation. + :param api_portal_resource: The API portal for the create or update operation. Is either a + model type or a IO type. Required. :type api_portal_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -199,84 +321,93 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + 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, service_name=service_name, api_portal_name=api_portal_name, api_portal_resource=api_portal_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, api_portal_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: @@ -286,25 +417,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the default API portal. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -316,98 +442,115 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, api_portal_name=api_portal_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ApiPortalResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApiPortalResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiPortalResourceCollection or the result of - cls(response) + :return: An iterator like instance of either ApiPortalResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -421,10 +564,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 @@ -434,79 +575,159 @@ 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.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore - @distributed_trace_async + @overload async def validate_domain( self, resource_group_name: str, service_name: str, api_portal_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the domains are valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_apps_operations.py index c1d78c25bbe7..7a138e986969 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_apps_operations.py @@ -6,46 +6,68 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._apps_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_get_resource_upload_url_request, build_list_request, build_set_active_deployments_request_initial, build_update_request_initial, build_validate_domain_request -T = TypeVar('T') +from ...operations._apps_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_get_resource_upload_url_request, + build_list_request, + build_set_active_deployments_request, + build_update_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AppsOperations: - """AppsOperations 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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`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_async async def get( @@ -55,102 +77,125 @@ async def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -158,21 +203,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,20 +304,24 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -206,84 +334,93 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -293,25 +430,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -323,83 +455,105 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore async def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -407,18 +561,97 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -426,20 +659,24 @@ async def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -452,104 +689,118 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncIterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AppResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -563,10 +814,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 @@ -576,112 +825,129 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace_async async def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore async def _set_active_deployments_initial( self, resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(active_deployment_collection, 'ActiveDeploymentCollection') - - request = build_set_active_deployments_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(active_deployment_collection, (IO, bytes)): + _content = active_deployment_collection + else: + _json = self._serialize.body(active_deployment_collection, "ActiveDeploymentCollection") + + request = build_set_active_deployments_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._set_active_deployments_initial.metadata['url'], + content=_content, + template_url=self._set_active_deployments_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]: @@ -689,18 +955,98 @@ async def _set_active_deployments_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _set_active_deployments_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + _set_active_deployments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + + @overload + async def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: _models.ActiveDeploymentCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ActiveDeploymentCollection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_set_active_deployments( @@ -708,21 +1054,25 @@ async def begin_set_active_deployments( resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AppResource"]: + ) -> AsyncLROPoller[_models.AppResource]: """Set existing Deployment under the app as active. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param active_deployment_collection: A list of Deployment name to be active. + :param active_deployment_collection: A list of Deployment name to be active. Is either a model + type or a IO type. Required. :type active_deployment_collection: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.ActiveDeploymentCollection + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ActiveDeploymentCollection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -735,119 +1085,206 @@ async def begin_set_active_deployments( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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._set_active_deployments_initial( + raw_result = await self._set_active_deployments_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, active_deployment_collection=active_deployment_collection, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_set_active_deployments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + begin_set_active_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore - @distributed_trace_async + @overload async def validate_domain( self, resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_bindings_operations.py index ff5b88481650..27ac9b510791 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_bindings_operations.py @@ -6,113 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._bindings_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._bindings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BindingsOperations: - """BindingsOperations 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 BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +141,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -160,21 +197,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +305,27 @@ async def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +338,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +360,73 @@ async def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -301,28 +436,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -334,46 +463,52 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore async def _update_initial( self, @@ -381,39 +516,55 @@ async def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -421,18 +572,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +677,27 @@ async def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BindingResource"]: + ) -> AsyncLROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +710,21 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +732,102 @@ async def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +841,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 @@ -599,8 +852,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_build_service_agent_pool_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_build_service_agent_pool_operations.py index 8c31315fc36f..ca0b2239ef04 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_build_service_agent_pool_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_build_service_agent_pool_operations.py @@ -6,104 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._build_service_agent_pool_operations import build_get_request, build_list_request, build_update_put_request_initial -T = TypeVar('T') +from ...operations._build_service_agent_pool_operations import ( + build_get_request, + build_list_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildServiceAgentPoolOperations: - """BuildServiceAgentPoolOperations 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 BuildServiceAgentPoolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service_agent_pool` 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, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildServiceAgentPoolResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildServiceAgentPoolResource"]: """List build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceAgentPoolResourceCollection or the - result of cls(response) + :return: An iterator like instance of either BuildServiceAgentPoolResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -117,10 +144,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 @@ -130,78 +155,78 @@ 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - agent_pool_name: str, - **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": + self, resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: """Get build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildServiceAgentPoolResource, or the result of cls(response) + :return: BuildServiceAgentPoolResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore async def _update_put_initial( self, @@ -209,39 +234,55 @@ async def _update_put_initial( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] + ) -> _models.BuildServiceAgentPoolResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(agent_pool_resource, 'BuildServiceAgentPoolResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(agent_pool_resource, (IO, bytes)): + _content = agent_pool_resource + else: + _json = self._serialize.body(agent_pool_resource, "BuildServiceAgentPoolResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -249,18 +290,104 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: _models.BuildServiceAgentPoolResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( @@ -269,23 +396,27 @@ async def begin_update_put( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BuildServiceAgentPoolResource"]: + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: """Create or update build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str - :param agent_pool_resource: Parameters for the update operation. + :param agent_pool_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type agent_pool_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -298,19 +429,21 @@ async def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, @@ -318,29 +451,32 @@ async def begin_update_put( agent_pool_resource=agent_pool_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_build_service_builder_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_build_service_builder_operations.py index 15ca47b7f806..f9fbcae717d0 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_build_service_builder_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_build_service_builder_operations.py @@ -6,113 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._build_service_builder_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._build_service_builder_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildServiceBuilderOperations: - """BuildServiceBuilderOperations 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 BuildServiceBuilderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service_builder` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> "_models.BuilderResource": + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.BuilderResource: """Get a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuilderResource, or the result of cls(response) + :return: BuilderResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +140,55 @@ async def _create_or_update_initial( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> "_models.BuilderResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] + ) -> _models.BuilderResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(builder_resource, 'BuilderResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(builder_resource, (IO, bytes)): + _content = builder_resource + else: + _json = self._serialize.body(builder_resource, "BuilderResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -160,18 +196,103 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: _models.BuilderResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,22 +301,27 @@ async def begin_create_or_update( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BuilderResource"]: + ) -> AsyncLROPoller[_models.BuilderResource]: """Create or update a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param builder_resource: The target builder for the create or update operation. - :type builder_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource + :param builder_resource: The target builder for the create or update operation. Is either a + model type or a IO type. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -208,19 +334,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -228,67 +356,73 @@ async def begin_create_or_update( builder_resource=builder_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, build_service_name: str, builder_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -298,28 +432,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_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. @@ -331,104 +459,119 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuilderResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuilderResource"]: """List KPack builders result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuilderResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BuilderResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -442,10 +585,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 @@ -455,8 +596,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_build_service_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_build_service_operations.py index 98ec096bafcf..482590dbc7bb 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_build_service_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_build_service_operations.py @@ -6,97 +6,135 @@ # Code generated 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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._build_service_operations import build_create_or_update_build_request, build_get_build_request, build_get_build_result_log_request, build_get_build_result_request, build_get_build_service_request, build_get_resource_upload_url_request, build_get_supported_buildpack_request, build_get_supported_stack_request, build_list_build_results_request, build_list_build_services_request, build_list_builds_request, build_list_supported_buildpacks_request, build_list_supported_stacks_request -T = TypeVar('T') +from ...operations._build_service_operations import ( + build_create_or_update_build_request, + build_get_build_request, + build_get_build_result_log_request, + build_get_build_result_request, + build_get_build_service_request, + build_get_resource_upload_url_request, + build_get_supported_buildpack_request, + build_get_supported_stack_request, + build_list_build_results_request, + build_list_build_services_request, + build_list_builds_request, + build_list_supported_buildpacks_request, + build_list_supported_stacks_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildServiceOperations: - """BuildServiceOperations 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 BuildServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service` 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_build_services( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildServiceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildService"]: """List build services resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceCollection or the result of - cls(response) + :return: An iterator like instance of either BuildService or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildService] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_services_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_services.metadata['url'], + template_url=self.list_build_services.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_build_services_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -110,10 +148,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 @@ -123,131 +159,142 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_build_services.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore + list_build_services.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore @distributed_trace_async async def get_build_service( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.BuildService": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.BuildService: """Get a build service resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildService, or the result of cls(response) + :return: BuildService or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildService - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildService"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildService] - request = build_get_build_service_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_service.metadata['url'], + template_url=self.get_build_service.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildService', pipeline_response) + deserialized = self._deserialize("BuildService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore - + get_build_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore @distributed_trace def list_builds( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Build"]: """List KPack builds. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildCollection or the result of cls(response) + :return: An iterator like instance of either Build or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_builds_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_builds.metadata['url'], + template_url=self.list_builds.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_builds_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -261,10 +308,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 @@ -274,78 +319,146 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_builds.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore + list_builds.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore @distributed_trace_async async def get_build( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> "_models.Build": + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> _models.Build: """Get a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - request = build_get_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build.metadata['url'], + template_url=self.get_build.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + get_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + @overload + async def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: _models.Build, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Build + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update_build( @@ -354,57 +467,77 @@ async def create_or_update_build( service_name: str, build_service_name: str, build_name: str, - build: "_models.Build", + build: Union[_models.Build, IO], **kwargs: Any - ) -> "_models.Build": + ) -> _models.Build: """Create or update a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build: Parameters for the create or update operation. - :type build: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Build + :param build: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type build: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Build or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - _json = self._serialize.body(build, 'Build') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build, (IO, bytes)): + _content = build + else: + _json = self._serialize.body(build, "Build") request = build_create_or_update_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_build.metadata['url'], + content=_content, + template_url=self.create_or_update_build.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]: @@ -412,81 +545,87 @@ async def create_or_update_build( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore - + create_or_update_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore @distributed_trace def list_build_results( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildResultCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildResult"]: """List KPack build results. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildResultCollection or the result of - cls(response) + :return: An iterator like instance of either BuildResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildResultCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_results_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_results.metadata['url'], + template_url=self.list_build_results.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_build_results_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - build_name=build_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -500,10 +639,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 @@ -513,11 +650,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_build_results.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore + list_build_results.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore @distributed_trace_async async def get_build_result( @@ -528,67 +663,74 @@ async def get_build_result( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResult": + ) -> _models.BuildResult: """Get a KPack build result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResult, or the result of cls(response) + :return: BuildResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResult] - request = build_get_build_result_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result.metadata['url'], + template_url=self.get_build_result.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResult', pipeline_response) + deserialized = self._deserialize("BuildResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore - + get_build_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore @distributed_trace_async async def get_build_result_log( @@ -599,387 +741,407 @@ async def get_build_result_log( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResultLog": + ) -> _models.BuildResultLog: """Get a KPack build result log download URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResultLog, or the result of cls(response) + :return: BuildResultLog or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildResultLog - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultLog"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultLog] - request = build_get_build_result_log_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result_log.metadata['url'], + template_url=self.get_build_result_log.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResultLog', pipeline_response) + deserialized = self._deserialize("BuildResultLog", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result_log.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore - + get_build_result_log.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore @distributed_trace_async async def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for build service, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore @distributed_trace_async async def list_supported_buildpacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedBuildpacksCollection: """Get all supported buildpacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpacksCollection, or the result of cls(response) + :return: SupportedBuildpacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SupportedBuildpacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpacksCollection] - request = build_list_supported_buildpacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_buildpacks.metadata['url'], + template_url=self.list_supported_buildpacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedBuildpacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_buildpacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore - + list_supported_buildpacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore @distributed_trace_async async def get_supported_buildpack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - buildpack_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, **kwargs: Any + ) -> _models.SupportedBuildpackResource: """Get the supported buildpack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param buildpack_name: The name of the buildpack resource. + :param buildpack_name: The name of the buildpack resource. Required. :type buildpack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpackResource, or the result of cls(response) + :return: SupportedBuildpackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SupportedBuildpackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpackResource] - request = build_get_supported_buildpack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, buildpack_name=buildpack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_buildpack.metadata['url'], + template_url=self.get_supported_buildpack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpackResource', pipeline_response) + deserialized = self._deserialize("SupportedBuildpackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_buildpack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore - + get_supported_buildpack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore @distributed_trace_async async def list_supported_stacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedStacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedStacksCollection: """Get all supported stacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStacksCollection, or the result of cls(response) + :return: SupportedStacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SupportedStacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStacksCollection] - request = build_list_supported_stacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_stacks.metadata['url'], + template_url=self.list_supported_stacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedStacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_stacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore - + list_supported_stacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore @distributed_trace_async async def get_supported_stack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - stack_name: str, - **kwargs: Any - ) -> "_models.SupportedStackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, **kwargs: Any + ) -> _models.SupportedStackResource: """Get the supported stack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param stack_name: The name of the stack resource. + :param stack_name: The name of the stack resource. Required. :type stack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStackResource, or the result of cls(response) + :return: SupportedStackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SupportedStackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStackResource] - request = build_get_supported_stack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, stack_name=stack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_stack.metadata['url'], + template_url=self.get_supported_stack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStackResource', pipeline_response) + deserialized = self._deserialize("SupportedStackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_stack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore - + get_supported_stack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_buildpack_binding_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_buildpack_binding_operations.py index 3cb2c20da4c6..54ae7491c322 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_buildpack_binding_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_buildpack_binding_operations.py @@ -6,46 +6,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._buildpack_binding_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._buildpack_binding_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildpackBindingOperations: - """BuildpackBindingOperations 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 BuildpackBindingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`buildpack_binding` 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( @@ -56,67 +74,74 @@ async def get( builder_name: str, buildpack_binding_name: str, **kwargs: Any - ) -> "_models.BuildpackBindingResource": + ) -> _models.BuildpackBindingResource: """Get a buildpack binding by name. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildpackBindingResource, or the result of cls(response) + :return: BuildpackBindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore async def _create_or_update_initial( self, @@ -125,40 +150,56 @@ async def _create_or_update_initial( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: Union[_models.BuildpackBindingResource, IO], **kwargs: Any - ) -> "_models.BuildpackBindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] + ) -> _models.BuildpackBindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(buildpack_binding, 'BuildpackBindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(buildpack_binding, (IO, bytes)): + _content = buildpack_binding + else: + _json = self._serialize.body(buildpack_binding, "BuildpackBindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -166,20 +207,19 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, @@ -187,25 +227,31 @@ async def begin_create_or_update( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: _models.BuildpackBindingResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.BuildpackBindingResource"]: + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: """Create or update a buildpack binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. :type buildpack_binding: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -218,19 +264,114 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] - 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, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildpackBindingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. Is + either a model type or a IO type. Required. + :type buildpack_binding: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildpackBindingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResource] + :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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -239,32 +380,35 @@ async def begin_create_or_update( buildpack_binding=buildpack_binding, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -275,33 +419,41 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements buildpack_binding_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -311,11 +463,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, service_name: str, @@ -327,15 +478,15 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Operation to delete a Buildpack Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_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. @@ -347,110 +498,124 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildpackBindingResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildpackBindingResource"]: """Handles requests to list all buildpack bindings in a builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildpackBindingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either BuildpackBindingResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, - service_name=service_name, - build_service_name=build_service_name, - builder_name=builder_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -464,10 +629,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 @@ -477,8 +640,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_certificates_operations.py index a5c1f9d48225..0d79ce2d9e38 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_certificates_operations.py @@ -6,147 +6,184 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'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_async async def get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(certificate_resource, 'CertificateResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -154,21 +191,101 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -176,21 +293,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CertificateResource"]: + ) -> AsyncLROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type certificate_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -203,84 +324,93 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -290,25 +420,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -320,98 +445,115 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -425,10 +567,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 @@ -438,8 +578,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_config_servers_operations.py index 0aee35587123..90aac46781fd 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_config_servers_operations.py @@ -6,139 +6,174 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._config_servers_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial, build_validate_request_initial -T = TypeVar('T') +from ...operations._config_servers_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConfigServersOperations: - """ConfigServersOperations 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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,37 +181,115 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,86 +302,107 @@ async def begin_update_put( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -276,37 +410,115 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerResource"]: + ) -> AsyncLROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -319,86 +531,107 @@ async def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore async def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_settings, 'ConfigServerSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -406,37 +639,115 @@ async def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerSettings + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -449,47 +760,54 @@ async def begin_validate( or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = await self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_configuration_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_configuration_services_operations.py index c7b36fd45a1b..e1707387592c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_configuration_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_configuration_services_operations.py @@ -6,147 +6,185 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._configuration_services_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_validate_request_initial -T = TypeVar('T') +from ...operations._configuration_services_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConfigurationServicesOperations: - """ConfigurationServicesOperations 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 ConfigurationServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`configuration_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any - ) -> "_models.ConfigurationServiceResource": + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> _models.ConfigurationServiceResource: """Get the Application Configuration Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigurationServiceResource, or the result of cls(response) + :return: ConfigurationServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] + ) -> _models.ConfigurationServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(configuration_service_resource, 'ConfigurationServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_service_resource, (IO, bytes)): + _content = configuration_service_resource + else: + _json = self._serialize.body(configuration_service_resource, "ConfigurationServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -154,18 +192,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: _models.ConfigurationServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -173,22 +293,26 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigurationServiceResource"]: + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: """Create the default Application Configuration Service or update the existing Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param configuration_service_resource: Parameters for the update operation. + :param configuration_service_resource: Parameters for the update operation. Is either a model + type or a IO type. Required. :type configuration_service_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -201,84 +325,93 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + 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, service_name=service_name, configuration_service_name=configuration_service_name, configuration_service_resource=configuration_service_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, configuration_service_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -288,25 +421,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Disable the default Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -318,98 +446,116 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, configuration_service_name=configuration_service_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ConfigurationServiceResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationServiceResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationServiceResourceCollection or the - result of cls(response) + :return: An iterator like instance of either ConfigurationServiceResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -423,10 +569,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 @@ -436,49 +580,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore async def _validate_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] + ) -> _models.ConfigurationServiceSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(settings, 'ConfigurationServiceSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(settings, (IO, bytes)): + _content = settings + else: + _json = self._serialize.body(settings, "ConfigurationServiceSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -486,18 +644,97 @@ async def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: _models.ConfigurationServiceSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_validate( @@ -505,20 +742,25 @@ async def begin_validate( resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConfigurationServiceSettingsValidateResult"]: + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: """Check if the Application Configuration Service settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param settings: Application Configuration Service settings to be validated. + :param settings: Application Configuration Service settings to be validated. Is either a model + type or a IO type. Required. :type settings: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettings + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -531,48 +773,55 @@ async def begin_validate( ConfigurationServiceSettingsValidateResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + 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._validate_initial( + raw_result = await self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, settings=settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_custom_domains_operations.py index bde04206fe5f..4833179d8e18 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_custom_domains_operations.py @@ -6,113 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._custom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CustomDomainsOperations: - """CustomDomainsOperations 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 CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +141,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -160,21 +197,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,22 +305,27 @@ async def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +338,21 @@ async def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -231,67 +360,73 @@ async def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -301,28 +436,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -334,46 +463,52 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore async def _update_initial( self, @@ -381,39 +516,55 @@ async def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -421,18 +572,103 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,22 +677,27 @@ async def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomainResource"]: + ) -> AsyncLROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -469,19 +710,21 @@ async def begin_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -489,90 +732,103 @@ async def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +842,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 @@ -599,8 +853,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_deployments_operations.py index e746cc785adc..93719ccb16cc 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_deployments_operations.py @@ -6,113 +6,142 @@ # Code generated 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, List, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._deployments_operations import build_create_or_update_request_initial, build_delete_request_initial, build_generate_heap_dump_request_initial, build_generate_thread_dump_request_initial, build_get_log_file_url_request, build_get_request, build_list_for_cluster_request, build_list_request, build_restart_request_initial, build_start_jfr_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._deployments_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_heap_dump_request, + build_generate_thread_dump_request, + build_get_log_file_url_request, + build_get_request, + build_list_for_cluster_request, + build_list_request, + build_restart_request, + build_start_jfr_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations 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 DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +149,55 @@ async def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -160,21 +205,107 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -183,23 +314,27 @@ async def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -212,19 +347,21 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -232,67 +369,73 @@ async def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -302,28 +445,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -335,46 +472,52 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore async def _update_initial( self, @@ -382,39 +525,55 @@ async def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -422,18 +581,104 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -442,23 +687,27 @@ async def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentResource"]: + ) -> AsyncLROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -471,19 +720,21 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -491,32 +742,35 @@ async def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -526,60 +780,72 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + ) -> AsyncIterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -593,10 +859,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 @@ -606,69 +870,76 @@ 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -682,10 +953,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 @@ -695,46 +964,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -744,28 +1014,22 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -777,81 +1041,90 @@ async def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -861,28 +1134,22 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -894,81 +1161,90 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore async def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -978,28 +1254,22 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async - async def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + async def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1011,98 +1281,107 @@ async def begin_restart( # 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace_async async def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1111,15 +1390,14 @@ async def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1127,39 +1405,55 @@ async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-st service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_heap_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_heap_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_heap_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_heap_dump_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]: @@ -1169,33 +1463,119 @@ async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - _generate_heap_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + _generate_heap_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + @overload + async def begin_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_heap_dump( # pylint: disable=inconsistent-return-statements + async def begin_generate_heap_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Generate Heap Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1206,19 +1586,21 @@ async def begin_generate_heap_dump( # pylint: disable=inconsistent-return-state 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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._generate_heap_dump_initial( + raw_result = await self._generate_heap_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1226,29 +1608,33 @@ async def begin_generate_heap_dump( # pylint: disable=inconsistent-return-state diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **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_generate_heap_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + begin_generate_heap_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1256,39 +1642,55 @@ async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return- service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_thread_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_thread_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_thread_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_thread_dump_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]: @@ -1298,33 +1700,119 @@ async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return- if cls: return cls(pipeline_response, None, {}) - _generate_thread_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + _generate_thread_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + @overload + async def begin_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_thread_dump( # pylint: disable=inconsistent-return-statements + async def begin_generate_thread_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Generate Thread Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1335,19 +1823,21 @@ async def begin_generate_thread_dump( # pylint: disable=inconsistent-return-sta 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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._generate_thread_dump_initial( + raw_result = await self._generate_thread_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1355,29 +1845,33 @@ async def begin_generate_thread_dump( # pylint: disable=inconsistent-return-sta diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **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_generate_thread_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + begin_generate_thread_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements self, @@ -1385,39 +1879,55 @@ async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_start_jfr_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_start_jfr_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._start_jfr_initial.metadata['url'], + content=_content, + template_url=self._start_jfr_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]: @@ -1427,33 +1937,119 @@ async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_jfr_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + _start_jfr_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + + @overload + async def begin_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_start_jfr( # pylint: disable=inconsistent-return-statements + async def begin_start_jfr( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Start JFR. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1464,19 +2060,21 @@ async def begin_start_jfr( # 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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._start_jfr_initial( + raw_result = await self._start_jfr_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1484,26 +2082,30 @@ async def begin_start_jfr( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **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_start_jfr.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + begin_start_jfr.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_gateway_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_gateway_custom_domains_operations.py index 97cbd33073fe..244f912bddb5 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_gateway_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_gateway_custom_domains_operations.py @@ -6,113 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._gateway_custom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._gateway_custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GatewayCustomDomainsOperations: - """GatewayCustomDomainsOperations 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 GatewayCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateway_custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.GatewayCustomDomainResource": + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any + ) -> _models.GatewayCustomDomainResource: """Get the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayCustomDomainResource, or the result of cls(response) + :return: GatewayCustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +140,55 @@ async def _create_or_update_initial( service_name: str, gateway_name: str, domain_name: str, - gateway_custom_domain_resource: "_models.GatewayCustomDomainResource", + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], **kwargs: Any - ) -> "_models.GatewayCustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] + ) -> _models.GatewayCustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_custom_domain_resource, 'GatewayCustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_custom_domain_resource, (IO, bytes)): + _content = gateway_custom_domain_resource + else: + _json = self._serialize.body(gateway_custom_domain_resource, "GatewayCustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: @@ -160,18 +196,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: _models.GatewayCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,24 +304,27 @@ async def begin_create_or_update( service_name: str, gateway_name: str, domain_name: str, - gateway_custom_domain_resource: "_models.GatewayCustomDomainResource", + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GatewayCustomDomainResource"]: + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: """Create or update the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_name: str :param gateway_custom_domain_resource: The gateway custom domain resource for the create or - update operation. + update operation. Is either a model type or a IO type. Required. :type gateway_custom_domain_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -210,19 +337,21 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + 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, service_name=service_name, gateway_name=gateway_name, @@ -230,67 +359,73 @@ async def begin_create_or_update( gateway_custom_domain_resource=gateway_custom_domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_name: str, domain_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: @@ -300,28 +435,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_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. @@ -333,104 +462,120 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.GatewayCustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayCustomDomainResource"]: """Handle requests to list all Spring Cloud Gateway custom domains. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayCustomDomainResourceCollection or the - result of cls(response) + :return: An iterator like instance of either GatewayCustomDomainResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, gateway_name=gateway_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, - service_name=service_name, - gateway_name=gateway_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -444,10 +589,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 @@ -457,8 +600,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_gateway_route_configs_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_gateway_route_configs_operations.py index 0ffbd29ea9c5..cd12d828c5d8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_gateway_route_configs_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_gateway_route_configs_operations.py @@ -6,113 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._gateway_route_configs_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._gateway_route_configs_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GatewayRouteConfigsOperations: - """GatewayRouteConfigsOperations 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 GatewayRouteConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateway_route_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_async async def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any - ) -> "_models.GatewayRouteConfigResource": + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any + ) -> _models.GatewayRouteConfigResource: """Get the Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayRouteConfigResource, or the result of cls(response) + :return: GatewayRouteConfigResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore async def _create_or_update_initial( self, @@ -120,39 +140,55 @@ async def _create_or_update_initial( service_name: str, gateway_name: str, route_config_name: str, - gateway_route_config_resource: "_models.GatewayRouteConfigResource", + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], **kwargs: Any - ) -> "_models.GatewayRouteConfigResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] + ) -> _models.GatewayRouteConfigResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_route_config_resource, 'GatewayRouteConfigResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_route_config_resource, (IO, bytes)): + _content = gateway_route_config_resource + else: + _json = self._serialize.body(gateway_route_config_resource, "GatewayRouteConfigResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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]: @@ -160,18 +196,108 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: _models.GatewayRouteConfigResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayRouteConfigResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayRouteConfigResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -180,25 +306,28 @@ async def begin_create_or_update( service_name: str, gateway_name: str, route_config_name: str, - gateway_route_config_resource: "_models.GatewayRouteConfigResource", + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GatewayRouteConfigResource"]: + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_name: str :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or - update operation. + update operation. Is either a model type or a IO type. Required. :type gateway_route_config_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -211,19 +340,21 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + 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, service_name=service_name, gateway_name=gateway_name, @@ -231,67 +362,73 @@ async def begin_create_or_update( gateway_route_config_resource=gateway_route_config_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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]: @@ -301,28 +438,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the Spring Cloud Gateway route config. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_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. @@ -334,104 +465,120 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.GatewayRouteConfigResourceCollection"]: + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayRouteConfigResource"]: """Handle requests to list all Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayRouteConfigResourceCollection or the result - of cls(response) + :return: An iterator like instance of either GatewayRouteConfigResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, gateway_name=gateway_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, - service_name=service_name, - gateway_name=gateway_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -445,10 +592,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 @@ -458,8 +603,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_gateways_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_gateways_operations.py index 71c8d9c05db1..2db64b850504 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_gateways_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_gateways_operations.py @@ -6,147 +6,185 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._gateways_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_validate_domain_request -T = TypeVar('T') +from ...operations._gateways_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GatewaysOperations: - """GatewaysOperations 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 GatewaysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateways` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> "_models.GatewayResource": + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> _models.GatewayResource: """Get the Spring Cloud Gateway and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayResource, or the result of cls(response) + :return: GatewayResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, gateway_name: str, - gateway_resource: "_models.GatewayResource", + gateway_resource: Union[_models.GatewayResource, IO], **kwargs: Any - ) -> "_models.GatewayResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] + ) -> _models.GatewayResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_resource, 'GatewayResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_resource, (IO, bytes)): + _content = gateway_resource + else: + _json = self._serialize.body(gateway_resource, "GatewayResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: @@ -154,18 +192,97 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: _models.GatewayResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -173,20 +290,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, gateway_name: str, - gateway_resource: "_models.GatewayResource", + gateway_resource: Union[_models.GatewayResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GatewayResource"]: + ) -> AsyncLROPoller[_models.GatewayResource]: """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param gateway_resource: The gateway for the create or update operation. - :type gateway_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource + :param gateway_resource: The gateway for the create or update operation. Is either a model type + or a IO type. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -199,84 +321,93 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + 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, service_name=service_name, gateway_name=gateway_name, gateway_resource=gateway_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: @@ -286,25 +417,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Disable the default Spring Cloud Gateway. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -316,98 +442,115 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, gateway_name=gateway_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.GatewayResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayResourceCollection or the result of - cls(response) + :return: An iterator like instance of either GatewayResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -421,10 +564,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 @@ -434,79 +575,159 @@ 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.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore - @distributed_trace_async + @overload async def validate_domain( self, resource_group_name: str, service_name: str, gateway_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the domains are valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_monitoring_settings_operations.py index 592b75bc3d15..cf2f47758b30 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_monitoring_settings_operations.py @@ -6,139 +6,175 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._monitoring_settings_operations import build_get_request, build_update_patch_request_initial, build_update_put_request_initial -T = TypeVar('T') +from ...operations._monitoring_settings_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MonitoringSettingsOperations: - """MonitoringSettingsOperations 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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -146,37 +182,115 @@ async def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,86 +303,107 @@ async def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = await self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore async def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -276,37 +411,115 @@ async def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.MonitoringSettingResource"]: + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -319,47 +532,52 @@ async def begin_update_patch( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = await self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_operations.py index 729c941a718c..c0c664652688 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_operations.py @@ -6,82 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.appplatform.v2022_05_01_preview.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,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 @@ -108,8 +134,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_runtime_versions_operations.py index c3875b6b2aae..386cdac9e336 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_runtime_versions_operations.py @@ -6,88 +6,104 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import 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._runtime_versions_operations import build_list_runtime_versions_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RuntimeVersionsOperations: - """RuntimeVersionsOperations 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 RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + async def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_service_registries_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_service_registries_operations.py index 33d846f49367..69423b0ca6d0 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_service_registries_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_service_registries_operations.py @@ -6,142 +6,167 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._service_registries_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._service_registries_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ServiceRegistriesOperations: - """ServiceRegistriesOperations 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 ServiceRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`service_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: """Get the Service Registry and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceRegistryResource, or the result of cls(response) + :return: ServiceRegistryResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._create_or_update_initial.metadata['url'], + 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]: @@ -149,35 +174,30 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace_async async def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceRegistryResource"]: + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceRegistryResource]: """Create the default Service Registry or update the existing Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -191,81 +211,90 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: @@ -275,25 +304,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Disable the default Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -305,98 +329,116 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceRegistryResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServiceRegistryResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceRegistryResourceCollection or the result of + :return: An iterator like instance of either ServiceRegistryResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -410,10 +452,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 @@ -423,8 +463,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_services_operations.py index f27d352f11c5..98e6f7bec0c5 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_services_operations.py @@ -6,141 +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, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._services_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_disable_test_endpoint_request, build_enable_test_endpoint_request, build_get_request, build_list_by_subscription_request, build_list_request, build_list_test_keys_request, build_regenerate_test_key_request, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._services_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_disable_test_endpoint_request, + build_enable_test_endpoint_request, + build_get_request, + build_list_by_subscription_request, + build_list_request, + build_list_test_keys_request, + build_regenerate_test_key_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ServicesOperations: - """ServicesOperations 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 ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -148,39 +189,43 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -193,81 +238,160 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] + :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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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]: @@ -277,22 +401,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -304,80 +422,98 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -385,36 +521,40 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceResource"]: + ) -> AsyncLROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -427,220 +567,377 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] + :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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace_async - async def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + async def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2022_05_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace_async async def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -650,98 +947,106 @@ async def disable_test_endpoint( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace_async async def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -751,22 +1056,16 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_stop(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Stop a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -778,75 +1077,86 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -856,22 +1166,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_start(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Start a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -883,147 +1187,227 @@ async def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2022_05_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(availability_parameters, 'NameAvailabilityParameters') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1037,10 +1421,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 @@ -1050,58 +1432,68 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1115,10 +1507,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 @@ -1128,8 +1518,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_skus_operations.py index b540584f4bc9..e4a59ec3267c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_skus_operations.py @@ -6,85 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SkusOperations: - """SkusOperations 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 SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) + :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -98,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 @@ -111,8 +135,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_storages_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_storages_operations.py index ca59fae045d2..a9152fb19997 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_storages_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/aio/operations/_storages_operations.py @@ -6,147 +6,184 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._storages_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._storages_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StoragesOperations: - """StoragesOperations 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 StoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.aio.AppPlatformManagementClient`'s + :attr:`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 get( - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any - ) -> "_models.StorageResource": + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> _models.StorageResource: """Get the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageResource, or the result of cls(response) + :return: StorageResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> "_models.StorageResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] + ) -> _models.StorageResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(storage_resource, 'StorageResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_resource, (IO, bytes)): + _content = storage_resource + else: + _json = self._serialize.body(storage_resource, "StorageResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -154,21 +191,100 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: _models.StorageResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -176,20 +292,25 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.StorageResource"]: + ) -> AsyncLROPoller[_models.StorageResource]: """Create or update storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str - :param storage_resource: Parameters for the create or update operation. - :type storage_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource + :param storage_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -202,84 +323,93 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + 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, service_name=service_name, storage_name=storage_name, storage_resource=storage_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, storage_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, storage_name=storage_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]: @@ -289,25 +419,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_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. @@ -319,98 +444,115 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, storage_name=storage_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.StorageResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageResource"]: """List all the storages of one Azure Spring Apps resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageResourceCollection or the result of - cls(response) + :return: An iterator like instance of either StorageResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -424,10 +566,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 @@ -437,8 +577,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/__init__.py index 6d9492be1914..501b707a7eef 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/__init__.py @@ -185,257 +185,259 @@ from ._models_py3 import UserSourceInfo from ._models_py3 import ValidationMessages - -from ._app_platform_management_client_enums import ( - ActionType, - ApiPortalProvisioningState, - AppResourceProvisioningState, - BindingType, - BuildProvisioningState, - BuildResultProvisioningState, - BuildServiceProvisioningState, - BuilderProvisioningState, - BuildpackBindingProvisioningState, - CertificateResourceProvisioningState, - ConfigServerState, - ConfigurationServiceProvisioningState, - CreatedByType, - CustomDomainResourceProvisioningState, - DeploymentResourceProvisioningState, - DeploymentResourceStatus, - GatewayProvisioningState, - HTTPSchemeType, - KPackBuildStageProvisioningState, - LastModifiedByType, - ManagedIdentityType, - MonitoringSettingState, - PowerState, - ProbeActionType, - ProvisioningState, - ResourceSkuRestrictionsReasonCode, - ResourceSkuRestrictionsType, - ServiceRegistryProvisioningState, - SkuScaleType, - StorageType, - SupportedRuntimePlatform, - SupportedRuntimeValue, - TestKeyType, - TrafficDirection, - Type, -) +from ._app_platform_management_client_enums import ActionType +from ._app_platform_management_client_enums import ApiPortalProvisioningState +from ._app_platform_management_client_enums import AppResourceProvisioningState +from ._app_platform_management_client_enums import BindingType +from ._app_platform_management_client_enums import BuildProvisioningState +from ._app_platform_management_client_enums import BuildResultProvisioningState +from ._app_platform_management_client_enums import BuildServiceProvisioningState +from ._app_platform_management_client_enums import BuilderProvisioningState +from ._app_platform_management_client_enums import BuildpackBindingProvisioningState +from ._app_platform_management_client_enums import CertificateResourceProvisioningState +from ._app_platform_management_client_enums import ConfigServerState +from ._app_platform_management_client_enums import ConfigurationServiceProvisioningState +from ._app_platform_management_client_enums import CreatedByType +from ._app_platform_management_client_enums import CustomDomainResourceProvisioningState +from ._app_platform_management_client_enums import DeploymentResourceProvisioningState +from ._app_platform_management_client_enums import DeploymentResourceStatus +from ._app_platform_management_client_enums import GatewayProvisioningState +from ._app_platform_management_client_enums import HTTPSchemeType +from ._app_platform_management_client_enums import KPackBuildStageProvisioningState +from ._app_platform_management_client_enums import LastModifiedByType +from ._app_platform_management_client_enums import ManagedIdentityType +from ._app_platform_management_client_enums import MonitoringSettingState +from ._app_platform_management_client_enums import PowerState +from ._app_platform_management_client_enums import ProbeActionType +from ._app_platform_management_client_enums import ProvisioningState +from ._app_platform_management_client_enums import ResourceSkuRestrictionsReasonCode +from ._app_platform_management_client_enums import ResourceSkuRestrictionsType +from ._app_platform_management_client_enums import ServiceRegistryProvisioningState +from ._app_platform_management_client_enums import SkuScaleType +from ._app_platform_management_client_enums import StorageType +from ._app_platform_management_client_enums import SupportedRuntimePlatform +from ._app_platform_management_client_enums import SupportedRuntimeValue +from ._app_platform_management_client_enums import TestKeyType +from ._app_platform_management_client_enums import TrafficDirection +from ._app_platform_management_client_enums import Type +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__ = [ - 'ActiveDeploymentCollection', - 'ApiPortalCustomDomainProperties', - 'ApiPortalCustomDomainResource', - 'ApiPortalCustomDomainResourceCollection', - 'ApiPortalInstance', - 'ApiPortalProperties', - 'ApiPortalResource', - 'ApiPortalResourceCollection', - 'ApiPortalResourceRequests', - 'AppResource', - 'AppResourceCollection', - 'AppResourceProperties', - 'AppVNetAddons', - 'ApplicationInsightsAgentVersions', - 'AvailableOperations', - 'AvailableRuntimeVersions', - 'AzureFileVolume', - 'BindingResource', - 'BindingResourceCollection', - 'BindingResourceProperties', - 'Build', - 'BuildCollection', - 'BuildProperties', - 'BuildResourceRequests', - 'BuildResult', - 'BuildResultCollection', - 'BuildResultLog', - 'BuildResultProperties', - 'BuildResultUserSourceInfo', - 'BuildService', - 'BuildServiceAgentPoolProperties', - 'BuildServiceAgentPoolResource', - 'BuildServiceAgentPoolResourceCollection', - 'BuildServiceAgentPoolSizeProperties', - 'BuildServiceCollection', - 'BuildServiceProperties', - 'BuildServicePropertiesResourceRequests', - 'BuildStageProperties', - 'BuilderProperties', - 'BuilderResource', - 'BuilderResourceCollection', - 'BuildpackBindingLaunchProperties', - 'BuildpackBindingProperties', - 'BuildpackBindingResource', - 'BuildpackBindingResourceCollection', - 'BuildpackProperties', - 'BuildpacksGroupProperties', - 'CertificateProperties', - 'CertificateResource', - 'CertificateResourceCollection', - 'CloudErrorBody', - 'ClusterResourceProperties', - 'ConfigServerGitProperty', - 'ConfigServerProperties', - 'ConfigServerResource', - 'ConfigServerSettings', - 'ConfigServerSettingsErrorRecord', - 'ConfigServerSettingsValidateResult', - 'ConfigurationServiceGitProperty', - 'ConfigurationServiceGitPropertyValidateResult', - 'ConfigurationServiceGitRepository', - 'ConfigurationServiceInstance', - 'ConfigurationServiceProperties', - 'ConfigurationServiceResource', - 'ConfigurationServiceResourceCollection', - 'ConfigurationServiceResourceRequests', - 'ConfigurationServiceSettings', - 'ConfigurationServiceSettingsValidateResult', - 'ContainerProbeSettings', - 'ContentCertificateProperties', - 'CustomContainer', - 'CustomContainerUserSourceInfo', - 'CustomDomainProperties', - 'CustomDomainResource', - 'CustomDomainResourceCollection', - 'CustomDomainValidatePayload', - 'CustomDomainValidateResult', - 'CustomPersistentDiskProperties', - 'CustomPersistentDiskResource', - 'DeploymentInstance', - 'DeploymentResource', - 'DeploymentResourceCollection', - 'DeploymentResourceProperties', - 'DeploymentSettings', - 'DiagnosticParameters', - 'Error', - 'ExecAction', - 'GatewayApiMetadataProperties', - 'GatewayApiRoute', - 'GatewayCorsProperties', - 'GatewayCustomDomainProperties', - 'GatewayCustomDomainResource', - 'GatewayCustomDomainResourceCollection', - 'GatewayInstance', - 'GatewayOperatorProperties', - 'GatewayOperatorResourceRequests', - 'GatewayProperties', - 'GatewayResource', - 'GatewayResourceCollection', - 'GatewayResourceRequests', - 'GatewayRouteConfigOpenApiProperties', - 'GatewayRouteConfigProperties', - 'GatewayRouteConfigResource', - 'GatewayRouteConfigResourceCollection', - 'GitPatternRepository', - 'HTTPGetAction', - 'ImageRegistryCredential', - 'IngressConfig', - 'JarUploadedUserSourceInfo', - 'KeyVaultCertificateProperties', - 'LoadedCertificate', - 'LogFileUrlResponse', - 'LogSpecification', - 'ManagedIdentityProperties', - 'MarketplaceResource', - 'MetricDimension', - 'MetricSpecification', - 'MonitoringSettingProperties', - 'MonitoringSettingResource', - 'NameAvailability', - 'NameAvailabilityParameters', - 'NetCoreZipUploadedUserSourceInfo', - 'NetworkProfile', - 'NetworkProfileOutboundIPs', - 'OperationDetail', - 'OperationDisplay', - 'OperationProperties', - 'PersistentDisk', - 'Probe', - 'ProbeAction', - 'ProxyResource', - 'RegenerateTestKeyRequestPayload', - 'RequiredTraffic', - 'Resource', - 'ResourceRequests', - 'ResourceSku', - 'ResourceSkuCapabilities', - 'ResourceSkuCollection', - 'ResourceSkuLocationInfo', - 'ResourceSkuRestrictionInfo', - 'ResourceSkuRestrictions', - 'ResourceSkuZoneDetails', - 'ResourceUploadDefinition', - 'ServiceRegistryInstance', - 'ServiceRegistryProperties', - 'ServiceRegistryResource', - 'ServiceRegistryResourceCollection', - 'ServiceRegistryResourceRequests', - 'ServiceResource', - 'ServiceResourceList', - 'ServiceSpecification', - 'ServiceVNetAddons', - 'Sku', - 'SkuCapacity', - 'SourceUploadedUserSourceInfo', - 'SsoProperties', - 'StackProperties', - 'StorageAccount', - 'StorageProperties', - 'StorageResource', - 'StorageResourceCollection', - 'SupportedBuildpackResource', - 'SupportedBuildpackResourceProperties', - 'SupportedBuildpacksCollection', - 'SupportedRuntimeVersion', - 'SupportedStackResource', - 'SupportedStackResourceProperties', - 'SupportedStacksCollection', - 'SystemData', - 'TCPSocketAction', - 'TemporaryDisk', - 'TestKeys', - 'TrackedResource', - 'TriggeredBuildResult', - 'UploadedUserSourceInfo', - 'UserAssignedManagedIdentity', - 'UserSourceInfo', - 'ValidationMessages', - 'ActionType', - 'ApiPortalProvisioningState', - 'AppResourceProvisioningState', - 'BindingType', - 'BuildProvisioningState', - 'BuildResultProvisioningState', - 'BuildServiceProvisioningState', - 'BuilderProvisioningState', - 'BuildpackBindingProvisioningState', - 'CertificateResourceProvisioningState', - 'ConfigServerState', - 'ConfigurationServiceProvisioningState', - 'CreatedByType', - 'CustomDomainResourceProvisioningState', - 'DeploymentResourceProvisioningState', - 'DeploymentResourceStatus', - 'GatewayProvisioningState', - 'HTTPSchemeType', - 'KPackBuildStageProvisioningState', - 'LastModifiedByType', - 'ManagedIdentityType', - 'MonitoringSettingState', - 'PowerState', - 'ProbeActionType', - 'ProvisioningState', - 'ResourceSkuRestrictionsReasonCode', - 'ResourceSkuRestrictionsType', - 'ServiceRegistryProvisioningState', - 'SkuScaleType', - 'StorageType', - 'SupportedRuntimePlatform', - 'SupportedRuntimeValue', - 'TestKeyType', - 'TrafficDirection', - 'Type', + "ActiveDeploymentCollection", + "ApiPortalCustomDomainProperties", + "ApiPortalCustomDomainResource", + "ApiPortalCustomDomainResourceCollection", + "ApiPortalInstance", + "ApiPortalProperties", + "ApiPortalResource", + "ApiPortalResourceCollection", + "ApiPortalResourceRequests", + "AppResource", + "AppResourceCollection", + "AppResourceProperties", + "AppVNetAddons", + "ApplicationInsightsAgentVersions", + "AvailableOperations", + "AvailableRuntimeVersions", + "AzureFileVolume", + "BindingResource", + "BindingResourceCollection", + "BindingResourceProperties", + "Build", + "BuildCollection", + "BuildProperties", + "BuildResourceRequests", + "BuildResult", + "BuildResultCollection", + "BuildResultLog", + "BuildResultProperties", + "BuildResultUserSourceInfo", + "BuildService", + "BuildServiceAgentPoolProperties", + "BuildServiceAgentPoolResource", + "BuildServiceAgentPoolResourceCollection", + "BuildServiceAgentPoolSizeProperties", + "BuildServiceCollection", + "BuildServiceProperties", + "BuildServicePropertiesResourceRequests", + "BuildStageProperties", + "BuilderProperties", + "BuilderResource", + "BuilderResourceCollection", + "BuildpackBindingLaunchProperties", + "BuildpackBindingProperties", + "BuildpackBindingResource", + "BuildpackBindingResourceCollection", + "BuildpackProperties", + "BuildpacksGroupProperties", + "CertificateProperties", + "CertificateResource", + "CertificateResourceCollection", + "CloudErrorBody", + "ClusterResourceProperties", + "ConfigServerGitProperty", + "ConfigServerProperties", + "ConfigServerResource", + "ConfigServerSettings", + "ConfigServerSettingsErrorRecord", + "ConfigServerSettingsValidateResult", + "ConfigurationServiceGitProperty", + "ConfigurationServiceGitPropertyValidateResult", + "ConfigurationServiceGitRepository", + "ConfigurationServiceInstance", + "ConfigurationServiceProperties", + "ConfigurationServiceResource", + "ConfigurationServiceResourceCollection", + "ConfigurationServiceResourceRequests", + "ConfigurationServiceSettings", + "ConfigurationServiceSettingsValidateResult", + "ContainerProbeSettings", + "ContentCertificateProperties", + "CustomContainer", + "CustomContainerUserSourceInfo", + "CustomDomainProperties", + "CustomDomainResource", + "CustomDomainResourceCollection", + "CustomDomainValidatePayload", + "CustomDomainValidateResult", + "CustomPersistentDiskProperties", + "CustomPersistentDiskResource", + "DeploymentInstance", + "DeploymentResource", + "DeploymentResourceCollection", + "DeploymentResourceProperties", + "DeploymentSettings", + "DiagnosticParameters", + "Error", + "ExecAction", + "GatewayApiMetadataProperties", + "GatewayApiRoute", + "GatewayCorsProperties", + "GatewayCustomDomainProperties", + "GatewayCustomDomainResource", + "GatewayCustomDomainResourceCollection", + "GatewayInstance", + "GatewayOperatorProperties", + "GatewayOperatorResourceRequests", + "GatewayProperties", + "GatewayResource", + "GatewayResourceCollection", + "GatewayResourceRequests", + "GatewayRouteConfigOpenApiProperties", + "GatewayRouteConfigProperties", + "GatewayRouteConfigResource", + "GatewayRouteConfigResourceCollection", + "GitPatternRepository", + "HTTPGetAction", + "ImageRegistryCredential", + "IngressConfig", + "JarUploadedUserSourceInfo", + "KeyVaultCertificateProperties", + "LoadedCertificate", + "LogFileUrlResponse", + "LogSpecification", + "ManagedIdentityProperties", + "MarketplaceResource", + "MetricDimension", + "MetricSpecification", + "MonitoringSettingProperties", + "MonitoringSettingResource", + "NameAvailability", + "NameAvailabilityParameters", + "NetCoreZipUploadedUserSourceInfo", + "NetworkProfile", + "NetworkProfileOutboundIPs", + "OperationDetail", + "OperationDisplay", + "OperationProperties", + "PersistentDisk", + "Probe", + "ProbeAction", + "ProxyResource", + "RegenerateTestKeyRequestPayload", + "RequiredTraffic", + "Resource", + "ResourceRequests", + "ResourceSku", + "ResourceSkuCapabilities", + "ResourceSkuCollection", + "ResourceSkuLocationInfo", + "ResourceSkuRestrictionInfo", + "ResourceSkuRestrictions", + "ResourceSkuZoneDetails", + "ResourceUploadDefinition", + "ServiceRegistryInstance", + "ServiceRegistryProperties", + "ServiceRegistryResource", + "ServiceRegistryResourceCollection", + "ServiceRegistryResourceRequests", + "ServiceResource", + "ServiceResourceList", + "ServiceSpecification", + "ServiceVNetAddons", + "Sku", + "SkuCapacity", + "SourceUploadedUserSourceInfo", + "SsoProperties", + "StackProperties", + "StorageAccount", + "StorageProperties", + "StorageResource", + "StorageResourceCollection", + "SupportedBuildpackResource", + "SupportedBuildpackResourceProperties", + "SupportedBuildpacksCollection", + "SupportedRuntimeVersion", + "SupportedStackResource", + "SupportedStackResourceProperties", + "SupportedStacksCollection", + "SystemData", + "TCPSocketAction", + "TemporaryDisk", + "TestKeys", + "TrackedResource", + "TriggeredBuildResult", + "UploadedUserSourceInfo", + "UserAssignedManagedIdentity", + "UserSourceInfo", + "ValidationMessages", + "ActionType", + "ApiPortalProvisioningState", + "AppResourceProvisioningState", + "BindingType", + "BuildProvisioningState", + "BuildResultProvisioningState", + "BuildServiceProvisioningState", + "BuilderProvisioningState", + "BuildpackBindingProvisioningState", + "CertificateResourceProvisioningState", + "ConfigServerState", + "ConfigurationServiceProvisioningState", + "CreatedByType", + "CustomDomainResourceProvisioningState", + "DeploymentResourceProvisioningState", + "DeploymentResourceStatus", + "GatewayProvisioningState", + "HTTPSchemeType", + "KPackBuildStageProvisioningState", + "LastModifiedByType", + "ManagedIdentityType", + "MonitoringSettingState", + "PowerState", + "ProbeActionType", + "ProvisioningState", + "ResourceSkuRestrictionsReasonCode", + "ResourceSkuRestrictionsType", + "ServiceRegistryProvisioningState", + "SkuScaleType", + "StorageType", + "SupportedRuntimePlatform", + "SupportedRuntimeValue", + "TestKeyType", + "TrafficDirection", + "Type", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/_app_platform_management_client_enums.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/_app_platform_management_client_enums.py index 593ef2e25130..391fd28425b8 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/_app_platform_management_client_enums.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/_app_platform_management_client_enums.py @@ -7,19 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - """ +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" INTERNAL = "Internal" -class ApiPortalProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the API portal. - """ + +class ApiPortalProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the API portal.""" CREATING = "Creating" UPDATING = "Updating" @@ -27,9 +25,9 @@ class ApiPortalProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, En FAILED = "Failed" DELETING = "Deleting" -class AppResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the App - """ + +class AppResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the App.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -37,9 +35,9 @@ class AppResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, UPDATING = "Updating" DELETING = "Deleting" -class BindingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Buildpack Binding Type - """ + +class BindingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Buildpack Binding Type.""" APPLICATION_INSIGHTS = "ApplicationInsights" APACHE_SKY_WALKING = "ApacheSkyWalking" @@ -48,9 +46,9 @@ class BindingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NEW_RELIC = "NewRelic" ELASTIC_APM = "ElasticAPM" -class BuilderProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Builder provision status. - """ + +class BuilderProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Builder provision status.""" CREATING = "Creating" UPDATING = "Updating" @@ -58,9 +56,9 @@ class BuilderProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" DELETING = "Deleting" -class BuildpackBindingProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Buildpack Binding. - """ + +class BuildpackBindingProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Buildpack Binding.""" CREATING = "Creating" UPDATING = "Updating" @@ -68,9 +66,9 @@ class BuildpackBindingProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, FAILED = "Failed" DELETING = "Deleting" -class BuildProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the KPack build result - """ + +class BuildProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" CREATING = "Creating" UPDATING = "Updating" @@ -78,9 +76,9 @@ class BuildProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) FAILED = "Failed" DELETING = "Deleting" -class BuildResultProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the KPack build result - """ + +class BuildResultProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" QUEUING = "Queuing" BUILDING = "Building" @@ -88,9 +86,9 @@ class BuildResultProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, FAILED = "Failed" DELETING = "Deleting" -class BuildServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the KPack build result - """ + +class BuildServiceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" CREATING = "Creating" UPDATING = "Updating" @@ -98,9 +96,9 @@ class BuildServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, FAILED = "Failed" DELETING = "Deleting" -class CertificateResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Certificate - """ + +class CertificateResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Certificate.""" CREATING = "Creating" UPDATING = "Updating" @@ -108,9 +106,9 @@ class CertificateResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMet FAILED = "Failed" DELETING = "Deleting" -class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the config server. - """ + +class ConfigServerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the config server.""" NOT_AVAILABLE = "NotAvailable" DELETED = "Deleted" @@ -118,9 +116,9 @@ class ConfigServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ConfigurationServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Application Configuration Service. - """ + +class ConfigurationServiceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Application Configuration Service.""" CREATING = "Creating" UPDATING = "Updating" @@ -128,18 +126,18 @@ class ConfigurationServiceProvisioningState(with_metaclass(CaseInsensitiveEnumMe FAILED = "Failed" DELETING = "Deleting" -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 CustomDomainResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Domain - """ + +class CustomDomainResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Domain.""" CREATING = "Creating" UPDATING = "Updating" @@ -147,25 +145,25 @@ class CustomDomainResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMe FAILED = "Failed" DELETING = "Deleting" -class DeploymentResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Deployment - """ + +class DeploymentResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Deployment.""" CREATING = "Creating" UPDATING = "Updating" SUCCEEDED = "Succeeded" FAILED = "Failed" -class DeploymentResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of the Deployment - """ + +class DeploymentResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the Deployment.""" STOPPED = "Stopped" RUNNING = "Running" -class GatewayProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Spring Cloud Gateway. - """ + +class GatewayProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Spring Cloud Gateway.""" CREATING = "Creating" UPDATING = "Updating" @@ -173,73 +171,74 @@ class GatewayProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" DELETING = "Deleting" -class HTTPSchemeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class HTTPSchemeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Scheme to use for connecting to the host. Defaults to HTTP. - + Possible enum values: - - + + * ``"HTTP"`` means that the scheme used will be http:// - * ``"HTTPS"`` means that the scheme used will be https:// + * ``"HTTPS"`` means that the scheme used will be https://. """ HTTP = "HTTP" HTTPS = "HTTPS" -class KPackBuildStageProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of this build stage resource. - """ + +class KPackBuildStageProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of this build stage resource.""" NOT_STARTED = "NotStarted" RUNNING = "Running" SUCCEEDED = "Succeeded" FAILED = "Failed" -class LastModifiedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that last modified the resource. - """ + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class ManagedIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the managed identity - """ + +class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the managed identity.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class MonitoringSettingState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Monitoring Setting. - """ + +class MonitoringSettingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Monitoring Setting.""" NOT_AVAILABLE = "NotAvailable" FAILED = "Failed" SUCCEEDED = "Succeeded" UPDATING = "Updating" -class PowerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Power state of the Service - """ + +class PowerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Power state of the Service.""" RUNNING = "Running" STOPPED = "Stopped" -class ProbeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the action to take to perform the health check. - """ + +class ProbeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the action to take to perform the health check.""" HTTP_GET_ACTION = "HTTPGetAction" TCP_SOCKET_ACTION = "TCPSocketAction" EXEC_ACTION = "ExecAction" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Service - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Service.""" CREATING = "Creating" UPDATING = "Updating" @@ -253,24 +252,25 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MOVED = "Moved" MOVE_FAILED = "MoveFailed" -class ResourceSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription' + 'NotAvailableForSubscription'. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ResourceSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets the type of restrictions. Possible values include: 'Location', 'Zone' - """ + +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the type of restrictions. Possible values include: 'Location', 'Zone'.""" LOCATION = "Location" ZONE = "Zone" -class ServiceRegistryProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the Service Registry. - """ + +class ServiceRegistryProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Service Registry.""" CREATING = "Creating" UPDATING = "Updating" @@ -278,52 +278,52 @@ class ServiceRegistryProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, s FAILED = "Failed" DELETING = "Deleting" -class SkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Gets or sets the type of the scale. - """ + +class SkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type of the scale.""" NONE = "None" MANUAL = "Manual" AUTOMATIC = "Automatic" -class StorageType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the storage. - """ + +class StorageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the storage.""" STORAGE_ACCOUNT = "StorageAccount" -class SupportedRuntimePlatform(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The platform of this runtime version (possible values: "Java" or ".NET"). - """ + +class SupportedRuntimePlatform(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The platform of this runtime version (possible values: "Java" or ".NET").""" JAVA = "Java" _NET_CORE = ".NET Core" -class SupportedRuntimeValue(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The raw value which could be passed to deployment CRUD operations. - """ + +class SupportedRuntimeValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The raw value which could be passed to deployment CRUD operations.""" JAVA8 = "Java_8" JAVA11 = "Java_11" JAVA17 = "Java_17" NET_CORE31 = "NetCore_31" -class TestKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the test key - """ + +class TestKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the test key.""" PRIMARY = "Primary" SECONDARY = "Secondary" -class TrafficDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The direction of required traffic - """ + +class TrafficDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The direction of required traffic.""" INBOUND = "Inbound" OUTBOUND = "Outbound" -class Type(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the underlying resource to mount as a persistent disk. - """ + +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the underlying resource to mount as a persistent disk.""" AZURE_FILE_VOLUME = "AzureFileVolume" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/_models_py3.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/_models_py3.py index a01cb1cec2ab..b4f1ae0f533d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/_models_py3.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,14 +8,23 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._app_platform_management_client_enums import * +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ActiveDeploymentCollection(msrest.serialization.Model): + +class ActiveDeploymentCollection(_serialization.Model): """Object that includes an array of Deployment resource name and set them as active. :ivar active_deployment_names: Collection of Deployment name. @@ -22,24 +32,19 @@ class ActiveDeploymentCollection(msrest.serialization.Model): """ _attribute_map = { - 'active_deployment_names': {'key': 'activeDeploymentNames', 'type': '[str]'}, + "active_deployment_names": {"key": "activeDeploymentNames", "type": "[str]"}, } - def __init__( - self, - *, - active_deployment_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, active_deployment_names: Optional[List[str]] = None, **kwargs): """ :keyword active_deployment_names: Collection of Deployment name. :paramtype active_deployment_names: list[str] """ - super(ActiveDeploymentCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.active_deployment_names = active_deployment_names -class ApiPortalCustomDomainProperties(msrest.serialization.Model): +class ApiPortalCustomDomainProperties(_serialization.Model): """The properties of custom domain for API portal. :ivar thumbprint: The thumbprint of bound certificate. @@ -47,24 +52,19 @@ class ApiPortalCustomDomainProperties(msrest.serialization.Model): """ _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, + "thumbprint": {"key": "thumbprint", "type": "str"}, } - def __init__( - self, - *, - thumbprint: Optional[str] = None, - **kwargs - ): + def __init__(self, *, thumbprint: Optional[str] = None, **kwargs): """ :keyword thumbprint: The thumbprint of bound certificate. :paramtype thumbprint: str """ - super(ApiPortalCustomDomainProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = thumbprint -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The core properties of ARM resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -80,26 +80,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 @@ -122,26 +118,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 ApiPortalCustomDomainResource(ProxyResource): @@ -163,36 +155,31 @@ class ApiPortalCustomDomainResource(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': 'ApiPortalCustomDomainProperties'}, + "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": "ApiPortalCustomDomainProperties"}, } - def __init__( - self, - *, - properties: Optional["ApiPortalCustomDomainProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ApiPortalCustomDomainProperties"] = None, **kwargs): """ :keyword properties: The properties of custom domain for API portal. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainProperties """ - super(ApiPortalCustomDomainResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ApiPortalCustomDomainResourceCollection(msrest.serialization.Model): +class ApiPortalCustomDomainResourceCollection(_serialization.Model): """Object that includes an array of API portal custom domain resources and a possible link for next set. :ivar value: Collection of API portal custom domain resources. @@ -204,14 +191,14 @@ class ApiPortalCustomDomainResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiPortalCustomDomainResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ApiPortalCustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ApiPortalCustomDomainResource"]] = None, + value: Optional[List["_models.ApiPortalCustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -223,12 +210,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ApiPortalCustomDomainResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ApiPortalInstance(msrest.serialization.Model): +class ApiPortalInstance(_serialization.Model): """Collection of instances belong to the API portal. Variables are only populated by the server, and will be ignored when sending a request. @@ -240,33 +227,29 @@ class ApiPortalInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiPortalInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class ApiPortalProperties(msrest.serialization.Model): +class ApiPortalProperties(_serialization.Model): """API portal properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the API portal. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the API portal. Known values are: "Creating", "Updating", + "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalProvisioningState :ivar public: Indicates whether the API portal exposes endpoint. @@ -289,32 +272,32 @@ class ApiPortalProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'url': {'readonly': True}, - 'resource_requests': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "url": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'public': {'key': 'public', 'type': 'bool'}, - 'url': {'key': 'url', 'type': 'str'}, - 'https_only': {'key': 'httpsOnly', 'type': 'bool'}, - 'gateway_ids': {'key': 'gatewayIds', 'type': '[str]'}, - 'source_urls': {'key': 'sourceUrls', 'type': '[str]'}, - 'sso_properties': {'key': 'ssoProperties', 'type': 'SsoProperties'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'ApiPortalResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[ApiPortalInstance]'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "gateway_ids": {"key": "gatewayIds", "type": "[str]"}, + "source_urls": {"key": "sourceUrls", "type": "[str]"}, + "sso_properties": {"key": "ssoProperties", "type": "SsoProperties"}, + "resource_requests": {"key": "resourceRequests", "type": "ApiPortalResourceRequests"}, + "instances": {"key": "instances", "type": "[ApiPortalInstance]"}, } def __init__( self, *, - public: Optional[bool] = False, - https_only: Optional[bool] = False, + public: bool = False, + https_only: bool = False, gateway_ids: Optional[List[str]] = None, source_urls: Optional[List[str]] = None, - sso_properties: Optional["SsoProperties"] = None, + sso_properties: Optional["_models.SsoProperties"] = None, **kwargs ): """ @@ -329,7 +312,7 @@ def __init__( :keyword sso_properties: Single sign-on related configuration. :paramtype sso_properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SsoProperties """ - super(ApiPortalProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.public = public self.url = None @@ -361,26 +344,26 @@ class ApiPortalResource(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': 'ApiPortalProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "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": "ApiPortalProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( self, *, - properties: Optional["ApiPortalProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.ApiPortalProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -389,12 +372,12 @@ def __init__( :keyword sku: Sku of the API portal resource. :paramtype sku: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Sku """ - super(ApiPortalResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.sku = sku -class ApiPortalResourceCollection(msrest.serialization.Model): +class ApiPortalResourceCollection(_serialization.Model): """Object that includes an array of API portal resources and a possible link for next set. :ivar value: Collection of API portal resources. @@ -405,16 +388,12 @@ class ApiPortalResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiPortalResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ApiPortalResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ApiPortalResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ApiPortalResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of API portal resources. @@ -423,12 +402,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ApiPortalResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ApiPortalResourceRequests(msrest.serialization.Model): +class ApiPortalResourceRequests(_serialization.Model): """Resource requests of the API portal. Variables are only populated by the server, and will be ignored when sending a request. @@ -440,27 +419,23 @@ class ApiPortalResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiPortalResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None -class ApplicationInsightsAgentVersions(msrest.serialization.Model): +class ApplicationInsightsAgentVersions(_serialization.Model): """Application Insights agent versions properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -470,20 +445,16 @@ class ApplicationInsightsAgentVersions(msrest.serialization.Model): """ _validation = { - 'java': {'readonly': True}, + "java": {"readonly": True}, } _attribute_map = { - 'java': {'key': 'java', 'type': 'str'}, + "java": {"key": "java", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApplicationInsightsAgentVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.java = None @@ -509,27 +480,27 @@ class AppResource(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': 'AppResourceProperties'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentityProperties'}, - 'location': {'key': 'location', 'type': 'str'}, + "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": "AppResourceProperties"}, + "identity": {"key": "identity", "type": "ManagedIdentityProperties"}, + "location": {"key": "location", "type": "str"}, } def __init__( self, *, - properties: Optional["AppResourceProperties"] = None, - identity: Optional["ManagedIdentityProperties"] = None, + properties: Optional["_models.AppResourceProperties"] = None, + identity: Optional["_models.ManagedIdentityProperties"] = None, location: Optional[str] = None, **kwargs ): @@ -543,13 +514,13 @@ def __init__( resource. :paramtype location: str """ - super(AppResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.identity = identity self.location = location -class AppResourceCollection(msrest.serialization.Model): +class AppResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of App resources. @@ -560,16 +531,12 @@ class AppResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AppResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AppResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["AppResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.AppResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of App resources. @@ -578,12 +545,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(AppResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class AppResourceProperties(msrest.serialization.Model): +class AppResourceProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """App resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -593,9 +560,9 @@ class AppResourceProperties(msrest.serialization.Model): :ivar url: URL of the App. :vartype url: str :ivar addon_configs: Collection of addons. - :vartype addon_configs: dict[str, dict[str, any]] - :ivar provisioning_state: Provisioning state of the App. Possible values include: "Succeeded", - "Failed", "Creating", "Updating", "Deleting". + :vartype addon_configs: dict[str, dict[str, JSON]] + :ivar provisioning_state: Provisioning state of the App. Known values are: "Succeeded", + "Failed", "Creating", "Updating", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResourceProvisioningState :ivar fqdn: Fully qualified dns Name. @@ -619,45 +586,45 @@ class AppResourceProperties(msrest.serialization.Model): """ _validation = { - 'url': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "url": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'public': {'key': 'public', 'type': 'bool'}, - 'url': {'key': 'url', 'type': 'str'}, - 'addon_configs': {'key': 'addonConfigs', 'type': '{{object}}'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'fqdn': {'key': 'fqdn', 'type': 'str'}, - 'https_only': {'key': 'httpsOnly', 'type': 'bool'}, - 'temporary_disk': {'key': 'temporaryDisk', 'type': 'TemporaryDisk'}, - 'persistent_disk': {'key': 'persistentDisk', 'type': 'PersistentDisk'}, - 'custom_persistent_disks': {'key': 'customPersistentDisks', 'type': '[CustomPersistentDiskResource]'}, - 'enable_end_to_end_tls': {'key': 'enableEndToEndTLS', 'type': 'bool'}, - 'loaded_certificates': {'key': 'loadedCertificates', 'type': '[LoadedCertificate]'}, - 'vnet_addons': {'key': 'vnetAddons', 'type': 'AppVNetAddons'}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "addon_configs": {"key": "addonConfigs", "type": "{{object}}"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "fqdn": {"key": "fqdn", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "temporary_disk": {"key": "temporaryDisk", "type": "TemporaryDisk"}, + "persistent_disk": {"key": "persistentDisk", "type": "PersistentDisk"}, + "custom_persistent_disks": {"key": "customPersistentDisks", "type": "[CustomPersistentDiskResource]"}, + "enable_end_to_end_tls": {"key": "enableEndToEndTLS", "type": "bool"}, + "loaded_certificates": {"key": "loadedCertificates", "type": "[LoadedCertificate]"}, + "vnet_addons": {"key": "vnetAddons", "type": "AppVNetAddons"}, } def __init__( self, *, public: Optional[bool] = None, - addon_configs: Optional[Dict[str, Dict[str, Any]]] = None, + addon_configs: Optional[Dict[str, Dict[str, JSON]]] = None, fqdn: Optional[str] = None, - https_only: Optional[bool] = False, - temporary_disk: Optional["TemporaryDisk"] = None, - persistent_disk: Optional["PersistentDisk"] = None, - custom_persistent_disks: Optional[List["CustomPersistentDiskResource"]] = None, - enable_end_to_end_tls: Optional[bool] = False, - loaded_certificates: Optional[List["LoadedCertificate"]] = None, - vnet_addons: Optional["AppVNetAddons"] = None, + https_only: bool = False, + temporary_disk: Optional["_models.TemporaryDisk"] = None, + persistent_disk: Optional["_models.PersistentDisk"] = None, + custom_persistent_disks: Optional[List["_models.CustomPersistentDiskResource"]] = None, + enable_end_to_end_tls: bool = False, + loaded_certificates: Optional[List["_models.LoadedCertificate"]] = None, + vnet_addons: Optional["_models.AppVNetAddons"] = None, **kwargs ): """ :keyword public: Indicates whether the App exposes public endpoint. :paramtype public: bool :keyword addon_configs: Collection of addons. - :paramtype addon_configs: dict[str, dict[str, any]] + :paramtype addon_configs: dict[str, dict[str, JSON]] :keyword fqdn: Fully qualified dns Name. :paramtype fqdn: str :keyword https_only: Indicate if only https is allowed. @@ -677,7 +644,7 @@ def __init__( :keyword vnet_addons: Additional App settings in vnet injection instance. :paramtype vnet_addons: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppVNetAddons """ - super(AppResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.public = public self.url = None self.addon_configs = addon_configs @@ -692,7 +659,7 @@ def __init__( self.vnet_addons = vnet_addons -class AppVNetAddons(msrest.serialization.Model): +class AppVNetAddons(_serialization.Model): """Additional App settings in vnet injection instance. Variables are only populated by the server, and will be ignored when sending a request. @@ -706,31 +673,26 @@ class AppVNetAddons(msrest.serialization.Model): """ _validation = { - 'public_endpoint_url': {'readonly': True}, + "public_endpoint_url": {"readonly": True}, } _attribute_map = { - 'public_endpoint': {'key': 'publicEndpoint', 'type': 'bool'}, - 'public_endpoint_url': {'key': 'publicEndpointUrl', 'type': 'str'}, + "public_endpoint": {"key": "publicEndpoint", "type": "bool"}, + "public_endpoint_url": {"key": "publicEndpointUrl", "type": "str"}, } - def __init__( - self, - *, - public_endpoint: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, public_endpoint: bool = False, **kwargs): """ :keyword public_endpoint: Indicates whether the App in vnet injection instance exposes endpoint which could be accessed from internet. :paramtype public_endpoint: bool """ - super(AppVNetAddons, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_endpoint = public_endpoint self.public_endpoint_url = None -class AvailableOperations(msrest.serialization.Model): +class AvailableOperations(_serialization.Model): """Available operations of the service. :ivar value: Collection of available operation details. @@ -741,16 +703,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. @@ -759,12 +717,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 AvailableRuntimeVersions(msrest.serialization.Model): +class AvailableRuntimeVersions(_serialization.Model): """AvailableRuntimeVersions. Variables are only populated by the server, and will be ignored when sending a request. @@ -775,35 +733,31 @@ class AvailableRuntimeVersions(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedRuntimeVersion]'}, + "value": {"key": "value", "type": "[SupportedRuntimeVersion]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AvailableRuntimeVersions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class CustomPersistentDiskProperties(msrest.serialization.Model): +class CustomPersistentDiskProperties(_serialization.Model): """Custom persistent disk resource payload. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureFileVolume. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureFileVolume All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the underlying resource to mount as a persistent - disk.Constant filled by server. Possible values include: "AzureFileVolume". + :ivar type: The type of the underlying resource to mount as a persistent disk. Required. + "AzureFileVolume" :vartype type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.Type - :ivar mount_path: Required. The mount path of the persistent disk. + :ivar mount_path: The mount path of the persistent disk. Required. :vartype mount_path: str :ivar read_only: Indicates whether the persistent disk is a readOnly one. :vartype read_only: bool @@ -812,38 +766,31 @@ class CustomPersistentDiskProperties(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, - 'mount_path': {'required': True}, + "type": {"required": True}, + "mount_path": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, - 'read_only': {'key': 'readOnly', 'type': 'bool'}, - 'mount_options': {'key': 'mountOptions', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "mount_path": {"key": "mountPath", "type": "str"}, + "read_only": {"key": "readOnly", "type": "bool"}, + "mount_options": {"key": "mountOptions", "type": "[str]"}, } - _subtype_map = { - 'type': {'AzureFileVolume': 'AzureFileVolume'} - } + _subtype_map = {"type": {"AzureFileVolume": "AzureFileVolume"}} def __init__( - self, - *, - mount_path: str, - read_only: Optional[bool] = None, - mount_options: Optional[List[str]] = None, - **kwargs + self, *, mount_path: str, read_only: Optional[bool] = None, mount_options: Optional[List[str]] = None, **kwargs ): """ - :keyword mount_path: Required. The mount path of the persistent disk. + :keyword mount_path: The mount path of the persistent disk. Required. :paramtype mount_path: str :keyword read_only: Indicates whether the persistent disk is a readOnly one. :paramtype read_only: bool :keyword mount_options: These are the mount options for a persistent disk. :paramtype mount_options: list[str] """ - super(CustomPersistentDiskProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None # type: Optional[str] self.mount_path = mount_path self.read_only = read_only @@ -855,31 +802,31 @@ class AzureFileVolume(CustomPersistentDiskProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the underlying resource to mount as a persistent - disk.Constant filled by server. Possible values include: "AzureFileVolume". + :ivar type: The type of the underlying resource to mount as a persistent disk. Required. + "AzureFileVolume" :vartype type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.Type - :ivar mount_path: Required. The mount path of the persistent disk. + :ivar mount_path: The mount path of the persistent disk. Required. :vartype mount_path: str :ivar read_only: Indicates whether the persistent disk is a readOnly one. :vartype read_only: bool :ivar mount_options: These are the mount options for a persistent disk. :vartype mount_options: list[str] - :ivar share_name: Required. The share name of the Azure File share. + :ivar share_name: The share name of the Azure File share. Required. :vartype share_name: str """ _validation = { - 'type': {'required': True}, - 'mount_path': {'required': True}, - 'share_name': {'required': True}, + "type": {"required": True}, + "mount_path": {"required": True}, + "share_name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, - 'read_only': {'key': 'readOnly', 'type': 'bool'}, - 'mount_options': {'key': 'mountOptions', 'type': '[str]'}, - 'share_name': {'key': 'shareName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "mount_path": {"key": "mountPath", "type": "str"}, + "read_only": {"key": "readOnly", "type": "bool"}, + "mount_options": {"key": "mountOptions", "type": "[str]"}, + "share_name": {"key": "shareName", "type": "str"}, } def __init__( @@ -892,17 +839,17 @@ def __init__( **kwargs ): """ - :keyword mount_path: Required. The mount path of the persistent disk. + :keyword mount_path: The mount path of the persistent disk. Required. :paramtype mount_path: str :keyword read_only: Indicates whether the persistent disk is a readOnly one. :paramtype read_only: bool :keyword mount_options: These are the mount options for a persistent disk. :paramtype mount_options: list[str] - :keyword share_name: Required. The share name of the Azure File share. + :keyword share_name: The share name of the Azure File share. Required. :paramtype share_name: str """ - super(AzureFileVolume, self).__init__(mount_path=mount_path, read_only=read_only, mount_options=mount_options, **kwargs) - self.type = 'AzureFileVolume' # type: str + super().__init__(mount_path=mount_path, read_only=read_only, mount_options=mount_options, **kwargs) + self.type = "AzureFileVolume" # type: str self.share_name = share_name @@ -925,36 +872,31 @@ class BindingResource(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': 'BindingResourceProperties'}, + "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": "BindingResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["BindingResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BindingResourceProperties"] = None, **kwargs): """ :keyword properties: Properties of the Binding resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResourceProperties """ - super(BindingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BindingResourceCollection(msrest.serialization.Model): +class BindingResourceCollection(_serialization.Model): """Object that includes an array of Binding resources and a possible link for next set. :ivar value: Collection of Binding resources. @@ -965,16 +907,12 @@ class BindingResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BindingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BindingResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BindingResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Binding resources. @@ -983,12 +921,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BindingResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BindingResourceProperties(msrest.serialization.Model): +class BindingResourceProperties(_serialization.Model): """Binding resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1002,7 +940,7 @@ class BindingResourceProperties(msrest.serialization.Model): :ivar key: The key of the bound resource. :vartype key: str :ivar binding_parameters: Binding parameters of the Binding resource. - :vartype binding_parameters: dict[str, any] + :vartype binding_parameters: dict[str, JSON] :ivar generated_properties: The generated Spring Boot property file for this binding. The secret will be deducted. :vartype generated_properties: str @@ -1013,22 +951,22 @@ class BindingResourceProperties(msrest.serialization.Model): """ _validation = { - 'resource_name': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'generated_properties': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, + "resource_name": {"readonly": True}, + "resource_type": {"readonly": True}, + "generated_properties": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, } _attribute_map = { - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'binding_parameters': {'key': 'bindingParameters', 'type': '{object}'}, - 'generated_properties': {'key': 'generatedProperties', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'str'}, - 'updated_at': {'key': 'updatedAt', 'type': 'str'}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "binding_parameters": {"key": "bindingParameters", "type": "{object}"}, + "generated_properties": {"key": "generatedProperties", "type": "str"}, + "created_at": {"key": "createdAt", "type": "str"}, + "updated_at": {"key": "updatedAt", "type": "str"}, } def __init__( @@ -1036,7 +974,7 @@ def __init__( *, resource_id: Optional[str] = None, key: Optional[str] = None, - binding_parameters: Optional[Dict[str, Any]] = None, + binding_parameters: Optional[Dict[str, JSON]] = None, **kwargs ): """ @@ -1045,9 +983,9 @@ def __init__( :keyword key: The key of the bound resource. :paramtype key: str :keyword binding_parameters: Binding parameters of the Binding resource. - :paramtype binding_parameters: dict[str, any] + :paramtype binding_parameters: dict[str, JSON] """ - super(BindingResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_name = None self.resource_type = None self.resource_id = resource_id @@ -1076,35 +1014,30 @@ class Build(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': 'BuildProperties'}, + "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": "BuildProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildProperties"] = None, **kwargs): """ :keyword properties: Properties of the build resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildProperties """ - super(Build, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildCollection(msrest.serialization.Model): +class BuildCollection(_serialization.Model): """Object that includes an array of Build resources and a possible link for next set. :ivar value: Collection of Build resources. @@ -1115,17 +1048,11 @@ class BuildCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Build]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Build]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Build"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Build"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Collection of Build resources. :paramtype value: list[~azure.mgmt.appplatform.v2022_05_01_preview.models.Build] @@ -1133,18 +1060,18 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuilderProperties(msrest.serialization.Model): +class BuilderProperties(_serialization.Model): """KPack Builder properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Builder provision status. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Builder provision status. Known values are: "Creating", "Updating", + "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderProvisioningState :ivar stack: Builder cluster stack property. @@ -1155,20 +1082,20 @@ class BuilderProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'stack': {'key': 'stack', 'type': 'StackProperties'}, - 'buildpack_groups': {'key': 'buildpackGroups', 'type': '[BuildpacksGroupProperties]'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "stack": {"key": "stack", "type": "StackProperties"}, + "buildpack_groups": {"key": "buildpackGroups", "type": "[BuildpacksGroupProperties]"}, } def __init__( self, *, - stack: Optional["StackProperties"] = None, - buildpack_groups: Optional[List["BuildpacksGroupProperties"]] = None, + stack: Optional["_models.StackProperties"] = None, + buildpack_groups: Optional[List["_models.BuildpacksGroupProperties"]] = None, **kwargs ): """ @@ -1178,7 +1105,7 @@ def __init__( :paramtype buildpack_groups: list[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpacksGroupProperties] """ - super(BuilderProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.stack = stack self.buildpack_groups = buildpack_groups @@ -1202,35 +1129,30 @@ class BuilderResource(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': 'BuilderProperties'}, + "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": "BuilderProperties"}, } - def __init__( - self, - *, - properties: Optional["BuilderProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuilderProperties"] = None, **kwargs): """ :keyword properties: Property of the Builder resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderProperties """ - super(BuilderResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuilderResourceCollection(msrest.serialization.Model): +class BuilderResourceCollection(_serialization.Model): """Object that includes an array of Builder resources and a possible link for next set. :ivar value: Collection of Builder resources. @@ -1241,16 +1163,12 @@ class BuilderResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuilderResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuilderResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BuilderResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BuilderResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Builder resources. @@ -1259,12 +1177,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuilderResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildpackBindingLaunchProperties(msrest.serialization.Model): +class BuildpackBindingLaunchProperties(_serialization.Model): """Buildpack Binding Launch Properties. :ivar properties: Non-sensitive properties for launchProperties. @@ -1274,16 +1192,12 @@ class BuildpackBindingLaunchProperties(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'secrets': {'key': 'secrets', 'type': '{str}'}, + "properties": {"key": "properties", "type": "{str}"}, + "secrets": {"key": "secrets", "type": "{str}"}, } def __init__( - self, - *, - properties: Optional[Dict[str, str]] = None, - secrets: Optional[Dict[str, str]] = None, - **kwargs + self, *, properties: Optional[Dict[str, str]] = None, secrets: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword properties: Non-sensitive properties for launchProperties. @@ -1291,21 +1205,21 @@ def __init__( :keyword secrets: Sensitive properties for launchProperties. :paramtype secrets: dict[str, str] """ - super(BuildpackBindingLaunchProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.secrets = secrets -class BuildpackBindingProperties(msrest.serialization.Model): +class BuildpackBindingProperties(_serialization.Model): """Properties of a buildpack binding. Variables are only populated by the server, and will be ignored when sending a request. - :ivar binding_type: Buildpack Binding Type. Possible values include: "ApplicationInsights", - "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", "ElasticAPM". + :ivar binding_type: Buildpack Binding Type. Known values are: "ApplicationInsights", + "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", and "ElasticAPM". :vartype binding_type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingType - :ivar provisioning_state: State of the Buildpack Binding. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Buildpack Binding. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingProvisioningState :ivar launch_properties: The object describes the buildpack binding launch properties. @@ -1314,31 +1228,31 @@ class BuildpackBindingProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'binding_type': {'key': 'bindingType', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'launch_properties': {'key': 'launchProperties', 'type': 'BuildpackBindingLaunchProperties'}, + "binding_type": {"key": "bindingType", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "launch_properties": {"key": "launchProperties", "type": "BuildpackBindingLaunchProperties"}, } def __init__( self, *, - binding_type: Optional[Union[str, "BindingType"]] = None, - launch_properties: Optional["BuildpackBindingLaunchProperties"] = None, + binding_type: Optional[Union[str, "_models.BindingType"]] = None, + launch_properties: Optional["_models.BuildpackBindingLaunchProperties"] = None, **kwargs ): """ - :keyword binding_type: Buildpack Binding Type. Possible values include: "ApplicationInsights", - "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", "ElasticAPM". + :keyword binding_type: Buildpack Binding Type. Known values are: "ApplicationInsights", + "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", and "ElasticAPM". :paramtype binding_type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingType :keyword launch_properties: The object describes the buildpack binding launch properties. :paramtype launch_properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingLaunchProperties """ - super(BuildpackBindingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.binding_type = binding_type self.provisioning_state = None self.launch_properties = launch_properties @@ -1363,36 +1277,31 @@ class BuildpackBindingResource(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': 'BuildpackBindingProperties'}, + "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": "BuildpackBindingProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildpackBindingProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildpackBindingProperties"] = None, **kwargs): """ :keyword properties: Properties of a buildpack binding. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingProperties """ - super(BuildpackBindingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildpackBindingResourceCollection(msrest.serialization.Model): +class BuildpackBindingResourceCollection(_serialization.Model): """Object that includes an array of BuildpackBinding resources and a possible link for next set. :ivar value: Collection of BuildpackBinding resources. @@ -1404,14 +1313,14 @@ class BuildpackBindingResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildpackBindingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildpackBindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["BuildpackBindingResource"]] = None, + value: Optional[List["_models.BuildpackBindingResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1423,12 +1332,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildpackBindingResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildpackProperties(msrest.serialization.Model): +class BuildpackProperties(_serialization.Model): """Buildpack properties payload. :ivar id: Id of the buildpack. @@ -1436,24 +1345,19 @@ class BuildpackProperties(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Id of the buildpack. :paramtype id: str """ - super(BuildpackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class BuildpacksGroupProperties(msrest.serialization.Model): +class BuildpacksGroupProperties(_serialization.Model): """Buildpack group properties of the Builder. :ivar name: Buildpack group name. @@ -1464,16 +1368,12 @@ class BuildpacksGroupProperties(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'buildpacks': {'key': 'buildpacks', 'type': '[BuildpackProperties]'}, + "name": {"key": "name", "type": "str"}, + "buildpacks": {"key": "buildpacks", "type": "[BuildpackProperties]"}, } def __init__( - self, - *, - name: Optional[str] = None, - buildpacks: Optional[List["BuildpackProperties"]] = None, - **kwargs + self, *, name: Optional[str] = None, buildpacks: Optional[List["_models.BuildpackProperties"]] = None, **kwargs ): """ :keyword name: Buildpack group name. @@ -1482,12 +1382,12 @@ def __init__( :paramtype buildpacks: list[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackProperties] """ - super(BuildpacksGroupProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.buildpacks = buildpacks -class BuildProperties(msrest.serialization.Model): +class BuildProperties(_serialization.Model): """Build resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1498,8 +1398,8 @@ class BuildProperties(msrest.serialization.Model): :vartype builder: str :ivar agent_pool: The resource id of agent pool. :vartype agent_pool: str - :ivar provisioning_state: Provisioning state of the KPack build result. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildProvisioningState :ivar env: The environment variables for this build. @@ -1513,18 +1413,18 @@ class BuildProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'triggered_build_result': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "triggered_build_result": {"readonly": True}, } _attribute_map = { - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'builder': {'key': 'builder', 'type': 'str'}, - 'agent_pool': {'key': 'agentPool', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'env': {'key': 'env', 'type': '{str}'}, - 'triggered_build_result': {'key': 'triggeredBuildResult', 'type': 'TriggeredBuildResult'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'BuildResourceRequests'}, + "relative_path": {"key": "relativePath", "type": "str"}, + "builder": {"key": "builder", "type": "str"}, + "agent_pool": {"key": "agentPool", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "env": {"key": "env", "type": "{str}"}, + "triggered_build_result": {"key": "triggeredBuildResult", "type": "TriggeredBuildResult"}, + "resource_requests": {"key": "resourceRequests", "type": "BuildResourceRequests"}, } def __init__( @@ -1534,7 +1434,7 @@ def __init__( builder: Optional[str] = None, agent_pool: Optional[str] = None, env: Optional[Dict[str, str]] = None, - resource_requests: Optional["BuildResourceRequests"] = None, + resource_requests: Optional["_models.BuildResourceRequests"] = None, **kwargs ): """ @@ -1550,7 +1450,7 @@ def __init__( :paramtype resource_requests: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildResourceRequests """ - super(BuildProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.relative_path = relative_path self.builder = builder self.agent_pool = agent_pool @@ -1560,7 +1460,7 @@ def __init__( self.resource_requests = resource_requests -class BuildResourceRequests(msrest.serialization.Model): +class BuildResourceRequests(_serialization.Model): """Resource request payload of Build Resource. :ivar cpu: Optional Cpu allocated to the build resource. 1 core can be represented by 1 or @@ -1574,17 +1474,11 @@ class BuildResourceRequests(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - *, - cpu: Optional[str] = "1", - memory: Optional[str] = "2Gi", - **kwargs - ): + def __init__(self, *, cpu: str = "1", memory: str = "2Gi", **kwargs): """ :keyword cpu: Optional Cpu allocated to the build resource. 1 core can be represented by 1 or 1000m. @@ -1595,7 +1489,7 @@ def __init__( The default value is 2Gi, this should not exceed build service agent pool memory size. :paramtype memory: str """ - super(BuildResourceRequests, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory = memory @@ -1618,35 +1512,30 @@ class BuildResult(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': 'BuildResultProperties'}, + "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": "BuildResultProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildResultProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildResultProperties"] = None, **kwargs): """ :keyword properties: Properties of the build result resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildResultProperties """ - super(BuildResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildResultCollection(msrest.serialization.Model): +class BuildResultCollection(_serialization.Model): """Object that includes an array of Build result resources and a possible link for next set. :ivar value: Collection of Build result resources. @@ -1657,16 +1546,12 @@ class BuildResultCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildResult]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BuildResult"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BuildResult"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Build result resources. @@ -1675,12 +1560,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildResultCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildResultLog(msrest.serialization.Model): +class BuildResultLog(_serialization.Model): """Build result log resource properties payload. :ivar blob_url: The public download URL of this build result log. @@ -1688,32 +1573,27 @@ class BuildResultLog(msrest.serialization.Model): """ _attribute_map = { - 'blob_url': {'key': 'blobUrl', 'type': 'str'}, + "blob_url": {"key": "blobUrl", "type": "str"}, } - def __init__( - self, - *, - blob_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, blob_url: Optional[str] = None, **kwargs): """ :keyword blob_url: The public download URL of this build result log. :paramtype blob_url: str """ - super(BuildResultLog, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob_url = blob_url -class BuildResultProperties(msrest.serialization.Model): +class BuildResultProperties(_serialization.Model): """Build result resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. :ivar name: The name of this build result. :vartype name: str - :ivar provisioning_state: Provisioning state of the KPack build result. Possible values - include: "Queuing", "Building", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Queuing", "Building", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildResultProvisioningState :ivar build_pod_name: The build pod name which can be used to get the build log streaming. @@ -1725,75 +1605,68 @@ class BuildResultProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'build_stages': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "build_stages": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'build_pod_name': {'key': 'buildPodName', 'type': 'str'}, - 'build_stages': {'key': 'buildStages', 'type': '[BuildStageProperties]'}, + "name": {"key": "name", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "build_pod_name": {"key": "buildPodName", "type": "str"}, + "build_stages": {"key": "buildStages", "type": "[BuildStageProperties]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - build_pod_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, build_pod_name: Optional[str] = None, **kwargs): """ :keyword name: The name of this build result. :paramtype name: str :keyword build_pod_name: The build pod name which can be used to get the build log streaming. :paramtype build_pod_name: str """ - super(BuildResultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.provisioning_state = None self.build_pod_name = build_pod_name self.build_stages = None -class UserSourceInfo(msrest.serialization.Model): +class UserSourceInfo(_serialization.Model): """Source information for a deployment. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: BuildResultUserSourceInfo, CustomContainerUserSourceInfo, UploadedUserSourceInfo. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + BuildResultUserSourceInfo, CustomContainerUserSourceInfo, UploadedUserSourceInfo All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, } _subtype_map = { - 'type': {'BuildResult': 'BuildResultUserSourceInfo', 'Container': 'CustomContainerUserSourceInfo', 'UploadedUserSourceInfo': 'UploadedUserSourceInfo'} + "type": { + "BuildResult": "BuildResultUserSourceInfo", + "Container": "CustomContainerUserSourceInfo", + "UploadedUserSourceInfo": "UploadedUserSourceInfo", + } } - def __init__( - self, - *, - version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, version: Optional[str] = None, **kwargs): """ :keyword version: Version of the source. :paramtype version: str """ - super(UserSourceInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None # type: Optional[str] self.version = version @@ -1803,7 +1676,7 @@ class BuildResultUserSourceInfo(UserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -1813,22 +1686,16 @@ class BuildResultUserSourceInfo(UserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'build_result_id': {'key': 'buildResultId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "build_result_id": {"key": "buildResultId", "type": "str"}, } - def __init__( - self, - *, - version: Optional[str] = None, - build_result_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, version: Optional[str] = None, build_result_id: Optional[str] = None, **kwargs): """ :keyword version: Version of the source. :paramtype version: str @@ -1836,8 +1703,8 @@ def __init__( Spring instance. :paramtype build_result_id: str """ - super(BuildResultUserSourceInfo, self).__init__(version=version, **kwargs) - self.type = 'BuildResult' # type: str + super().__init__(version=version, **kwargs) + self.type = "BuildResult" # type: str self.build_result_id = build_result_id @@ -1859,36 +1726,31 @@ class BuildService(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': 'BuildServiceProperties'}, + "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": "BuildServiceProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildServiceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildServiceProperties"] = None, **kwargs): """ :keyword properties: Properties of the build resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceProperties """ - super(BuildService, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildServiceAgentPoolProperties(msrest.serialization.Model): +class BuildServiceAgentPoolProperties(_serialization.Model): """Build service agent pool properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1901,26 +1763,21 @@ class BuildServiceAgentPoolProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'pool_size': {'key': 'poolSize', 'type': 'BuildServiceAgentPoolSizeProperties'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "pool_size": {"key": "poolSize", "type": "BuildServiceAgentPoolSizeProperties"}, } - def __init__( - self, - *, - pool_size: Optional["BuildServiceAgentPoolSizeProperties"] = None, - **kwargs - ): + def __init__(self, *, pool_size: Optional["_models.BuildServiceAgentPoolSizeProperties"] = None, **kwargs): """ :keyword pool_size: build service agent pool size properties. :paramtype pool_size: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolSizeProperties """ - super(BuildServiceAgentPoolProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.pool_size = pool_size @@ -1944,36 +1801,31 @@ class BuildServiceAgentPoolResource(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': 'BuildServiceAgentPoolProperties'}, + "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": "BuildServiceAgentPoolProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildServiceAgentPoolProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildServiceAgentPoolProperties"] = None, **kwargs): """ :keyword properties: build service agent pool properties. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolProperties """ - super(BuildServiceAgentPoolResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildServiceAgentPoolResourceCollection(msrest.serialization.Model): +class BuildServiceAgentPoolResourceCollection(_serialization.Model): """Object that includes an array of build service agent pool resources and a possible link for next set. :ivar value: Collection of build service agent pool resource. @@ -1985,14 +1837,14 @@ class BuildServiceAgentPoolResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildServiceAgentPoolResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildServiceAgentPoolResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["BuildServiceAgentPoolResource"]] = None, + value: Optional[List["_models.BuildServiceAgentPoolResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2004,12 +1856,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildServiceAgentPoolResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildServiceAgentPoolSizeProperties(msrest.serialization.Model): +class BuildServiceAgentPoolSizeProperties(_serialization.Model): """Build service agent pool size properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -2023,33 +1875,28 @@ class BuildServiceAgentPoolSizeProperties(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The name of build service agent pool size. :paramtype name: str """ - super(BuildServiceAgentPoolSizeProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.cpu = None self.memory = None -class BuildServiceCollection(msrest.serialization.Model): +class BuildServiceCollection(_serialization.Model): """Object that includes an array of Build service resources and a possible link for next set. :ivar value: Collection of Build service resources. @@ -2060,16 +1907,12 @@ class BuildServiceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildService]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildService]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BuildService"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BuildService"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Build service resources. @@ -2078,20 +1921,20 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(BuildServiceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildServiceProperties(msrest.serialization.Model): +class BuildServiceProperties(_serialization.Model): """Build service resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. :ivar k_pack_version: The installed KPack version in this build service. :vartype k_pack_version: str - :ivar provisioning_state: Provisioning state of the KPack build result. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceProvisioningState :ivar resource_requests: The runtime resource configuration of this build service. @@ -2100,20 +1943,20 @@ class BuildServiceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'k_pack_version': {'key': 'kPackVersion', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'BuildServicePropertiesResourceRequests'}, + "k_pack_version": {"key": "kPackVersion", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "BuildServicePropertiesResourceRequests"}, } def __init__( self, *, k_pack_version: Optional[str] = None, - resource_requests: Optional["BuildServicePropertiesResourceRequests"] = None, + resource_requests: Optional["_models.BuildServicePropertiesResourceRequests"] = None, **kwargs ): """ @@ -2123,13 +1966,13 @@ def __init__( :paramtype resource_requests: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServicePropertiesResourceRequests """ - super(BuildServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.k_pack_version = k_pack_version self.provisioning_state = None self.resource_requests = resource_requests -class BuildServicePropertiesResourceRequests(msrest.serialization.Model): +class BuildServicePropertiesResourceRequests(_serialization.Model): """The runtime resource configuration of this build service. Variables are only populated by the server, and will be ignored when sending a request. @@ -2141,71 +1984,63 @@ class BuildServicePropertiesResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BuildServicePropertiesResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None -class BuildStageProperties(msrest.serialization.Model): +class BuildStageProperties(_serialization.Model): """The build stage (init-container and container) resources in build pod. Variables are only populated by the server, and will be ignored when sending a request. :ivar name: The name of this build stage resource. :vartype name: str - :ivar status: The provisioning state of this build stage resource. Possible values include: - "NotStarted", "Running", "Succeeded", "Failed". + :ivar status: The provisioning state of this build stage resource. Known values are: + "NotStarted", "Running", "Succeeded", and "Failed". :vartype status: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.KPackBuildStageProvisioningState """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BuildStageProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """Certificate resource payload. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ContentCertificateProperties, KeyVaultCertificateProperties. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContentCertificateProperties, KeyVaultCertificateProperties Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -2221,47 +2056,46 @@ class CertificateProperties(msrest.serialization.Model): :vartype subject_name: str :ivar dns_names: The domain list of certificate. :vartype dns_names: list[str] - :ivar provisioning_state: Provisioning state of the Certificate. Possible values include: - "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the Certificate. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResourceProvisioningState """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } _subtype_map = { - 'type': {'ContentCertificate': 'ContentCertificateProperties', 'KeyVaultCertificate': 'KeyVaultCertificateProperties'} + "type": { + "ContentCertificate": "ContentCertificateProperties", + "KeyVaultCertificate": "KeyVaultCertificateProperties", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificateProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None # type: Optional[str] self.thumbprint = None self.issuer = None @@ -2291,35 +2125,30 @@ class CertificateResource(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': 'CertificateProperties'}, + "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": "CertificateProperties"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: Properties of the certificate resource payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateProperties """ - super(CertificateResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CertificateResourceCollection(msrest.serialization.Model): +class CertificateResourceCollection(_serialization.Model): """Collection compose of certificate resources list and a possible link for next page. :ivar value: The certificate resources list. @@ -2329,16 +2158,12 @@ class CertificateResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CertificateResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CertificateResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CertificateResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The certificate resources list. @@ -2346,12 +2171,12 @@ def __init__( :keyword next_link: The link to next page of certificate list. :paramtype next_link: str """ - super(CertificateResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -2368,10 +2193,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -2380,7 +2205,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -2396,21 +2221,21 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.appplatform.v2022_05_01_preview.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class ClusterResourceProperties(msrest.serialization.Model): +class ClusterResourceProperties(_serialization.Model): """Service properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Provisioning state of the Service. Possible values include: - "Creating", "Updating", "Starting", "Stopping", "Deleting", "Deleted", "Succeeded", "Failed", - "Moving", "Moved", "MoveFailed". + :ivar provisioning_state: Provisioning state of the Service. Known values are: "Creating", + "Updating", "Starting", "Stopping", "Deleting", "Deleted", "Succeeded", "Failed", "Moving", + "Moved", and "MoveFailed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ProvisioningState :ivar network_profile: Network profile of the Service. @@ -2421,7 +2246,7 @@ class ClusterResourceProperties(msrest.serialization.Model): :vartype version: int :ivar service_id: ServiceInstanceEntity GUID which uniquely identifies a created resource. :vartype service_id: str - :ivar power_state: Power state of the Service. Possible values include: "Running", "Stopped". + :ivar power_state: Power state of the Service. Known values are: "Running" and "Stopped". :vartype power_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.PowerState :ivar zone_redundant: :vartype zone_redundant: bool @@ -2433,32 +2258,32 @@ class ClusterResourceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'version': {'readonly': True}, - 'service_id': {'readonly': True}, - 'power_state': {'readonly': True}, - 'fqdn': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "service_id": {"readonly": True}, + "power_state": {"readonly": True}, + "fqdn": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'network_profile': {'key': 'networkProfile', 'type': 'NetworkProfile'}, - 'vnet_addons': {'key': 'vnetAddons', 'type': 'ServiceVNetAddons'}, - 'version': {'key': 'version', 'type': 'int'}, - 'service_id': {'key': 'serviceId', 'type': 'str'}, - 'power_state': {'key': 'powerState', 'type': 'str'}, - 'zone_redundant': {'key': 'zoneRedundant', 'type': 'bool'}, - 'fqdn': {'key': 'fqdn', 'type': 'str'}, - 'marketplace_resource': {'key': 'marketplaceResource', 'type': 'MarketplaceResource'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "network_profile": {"key": "networkProfile", "type": "NetworkProfile"}, + "vnet_addons": {"key": "vnetAddons", "type": "ServiceVNetAddons"}, + "version": {"key": "version", "type": "int"}, + "service_id": {"key": "serviceId", "type": "str"}, + "power_state": {"key": "powerState", "type": "str"}, + "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, + "fqdn": {"key": "fqdn", "type": "str"}, + "marketplace_resource": {"key": "marketplaceResource", "type": "MarketplaceResource"}, } def __init__( self, *, - network_profile: Optional["NetworkProfile"] = None, - vnet_addons: Optional["ServiceVNetAddons"] = None, - zone_redundant: Optional[bool] = False, - marketplace_resource: Optional["MarketplaceResource"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + vnet_addons: Optional["_models.ServiceVNetAddons"] = None, + zone_redundant: bool = False, + marketplace_resource: Optional["_models.MarketplaceResource"] = None, **kwargs ): """ @@ -2472,7 +2297,7 @@ def __init__( :paramtype marketplace_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.MarketplaceResource """ - super(ClusterResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.network_profile = network_profile self.vnet_addons = vnet_addons @@ -2484,7 +2309,7 @@ def __init__( self.marketplace_resource = marketplace_resource -class ConfigServerGitProperty(msrest.serialization.Model): +class ConfigServerGitProperty(_serialization.Model): """Property of git. All required parameters must be populated in order to send to Azure. @@ -2492,7 +2317,7 @@ class ConfigServerGitProperty(msrest.serialization.Model): :ivar repositories: Repositories of git. :vartype repositories: list[~azure.mgmt.appplatform.v2022_05_01_preview.models.GitPatternRepository] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -2513,27 +2338,27 @@ class ConfigServerGitProperty(msrest.serialization.Model): """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'repositories': {'key': 'repositories', 'type': '[GitPatternRepository]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "repositories": {"key": "repositories", "type": "[GitPatternRepository]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( self, *, uri: str, - repositories: Optional[List["GitPatternRepository"]] = None, + repositories: Optional[List["_models.GitPatternRepository"]] = None, label: Optional[str] = None, search_paths: Optional[List[str]] = None, username: Optional[str] = None, @@ -2548,7 +2373,7 @@ def __init__( :keyword repositories: Repositories of git. :paramtype repositories: list[~azure.mgmt.appplatform.v2022_05_01_preview.models.GitPatternRepository] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -2567,7 +2392,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(ConfigServerGitProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.repositories = repositories self.uri = uri self.label = label @@ -2580,13 +2405,13 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ConfigServerProperties(msrest.serialization.Model): +class ConfigServerProperties(_serialization.Model): """Config server git properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the config server. Possible values include: "NotAvailable", - "Deleted", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the config server. Known values are: "NotAvailable", + "Deleted", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerState :ivar error: Error when apply config server settings. @@ -2596,20 +2421,20 @@ class ConfigServerProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'config_server': {'key': 'configServer', 'type': 'ConfigServerSettings'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "config_server": {"key": "configServer", "type": "ConfigServerSettings"}, } def __init__( self, *, - error: Optional["Error"] = None, - config_server: Optional["ConfigServerSettings"] = None, + error: Optional["_models.Error"] = None, + config_server: Optional["_models.ConfigServerSettings"] = None, **kwargs ): """ @@ -2619,7 +2444,7 @@ def __init__( :paramtype config_server: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerSettings """ - super(ConfigServerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.config_server = config_server @@ -2643,36 +2468,31 @@ class ConfigServerResource(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': 'ConfigServerProperties'}, + "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": "ConfigServerProperties"}, } - def __init__( - self, - *, - properties: Optional["ConfigServerProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ConfigServerProperties"] = None, **kwargs): """ :keyword properties: Properties of the Config Server resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerProperties """ - super(ConfigServerResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ConfigServerSettings(msrest.serialization.Model): +class ConfigServerSettings(_serialization.Model): """The settings of config server. :ivar git_property: Property of git environment. @@ -2681,25 +2501,20 @@ class ConfigServerSettings(msrest.serialization.Model): """ _attribute_map = { - 'git_property': {'key': 'gitProperty', 'type': 'ConfigServerGitProperty'}, + "git_property": {"key": "gitProperty", "type": "ConfigServerGitProperty"}, } - def __init__( - self, - *, - git_property: Optional["ConfigServerGitProperty"] = None, - **kwargs - ): + def __init__(self, *, git_property: Optional["_models.ConfigServerGitProperty"] = None, **kwargs): """ :keyword git_property: Property of git environment. :paramtype git_property: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerGitProperty """ - super(ConfigServerSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property = git_property -class ConfigServerSettingsErrorRecord(msrest.serialization.Model): +class ConfigServerSettingsErrorRecord(_serialization.Model): """Error record of the config server settings. :ivar name: The name of the config server settings error record. @@ -2711,18 +2526,13 @@ class ConfigServerSettingsErrorRecord(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'messages': {'key': 'messages', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, } def __init__( - self, - *, - name: Optional[str] = None, - uri: Optional[str] = None, - messages: Optional[List[str]] = None, - **kwargs + self, *, name: Optional[str] = None, uri: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs ): """ :keyword name: The name of the config server settings error record. @@ -2732,13 +2542,13 @@ def __init__( :keyword messages: The detail error messages of the record. :paramtype messages: list[str] """ - super(ConfigServerSettingsErrorRecord, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.uri = uri self.messages = messages -class ConfigServerSettingsValidateResult(msrest.serialization.Model): +class ConfigServerSettingsValidateResult(_serialization.Model): """Validation result for config server settings. :ivar is_valid: Indicate if the config server settings are valid. @@ -2749,15 +2559,15 @@ class ConfigServerSettingsValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'details': {'key': 'details', 'type': '[ConfigServerSettingsErrorRecord]'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "details": {"key": "details", "type": "[ConfigServerSettingsErrorRecord]"}, } def __init__( self, *, is_valid: Optional[bool] = None, - details: Optional[List["ConfigServerSettingsErrorRecord"]] = None, + details: Optional[List["_models.ConfigServerSettingsErrorRecord"]] = None, **kwargs ): """ @@ -2767,12 +2577,12 @@ def __init__( :paramtype details: list[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerSettingsErrorRecord] """ - super(ConfigServerSettingsValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.details = details -class ConfigurationServiceGitProperty(msrest.serialization.Model): +class ConfigurationServiceGitProperty(_serialization.Model): """Property of git environment. :ivar repositories: Repositories of Application Configuration Service git property. @@ -2781,25 +2591,20 @@ class ConfigurationServiceGitProperty(msrest.serialization.Model): """ _attribute_map = { - 'repositories': {'key': 'repositories', 'type': '[ConfigurationServiceGitRepository]'}, + "repositories": {"key": "repositories", "type": "[ConfigurationServiceGitRepository]"}, } - def __init__( - self, - *, - repositories: Optional[List["ConfigurationServiceGitRepository"]] = None, - **kwargs - ): + def __init__(self, *, repositories: Optional[List["_models.ConfigurationServiceGitRepository"]] = None, **kwargs): """ :keyword repositories: Repositories of Application Configuration Service git property. :paramtype repositories: list[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceGitRepository] """ - super(ConfigurationServiceGitProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.repositories = repositories -class ConfigurationServiceGitPropertyValidateResult(msrest.serialization.Model): +class ConfigurationServiceGitPropertyValidateResult(_serialization.Model): """Validation result for configuration service settings. :ivar is_valid: Indicate if the configuration service settings are valid. @@ -2810,15 +2615,15 @@ class ConfigurationServiceGitPropertyValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'git_repos_validation_result': {'key': 'gitReposValidationResult', 'type': '[ValidationMessages]'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "git_repos_validation_result": {"key": "gitReposValidationResult", "type": "[ValidationMessages]"}, } def __init__( self, *, is_valid: Optional[bool] = None, - git_repos_validation_result: Optional[List["ValidationMessages"]] = None, + git_repos_validation_result: Optional[List["_models.ValidationMessages"]] = None, **kwargs ): """ @@ -2828,23 +2633,23 @@ def __init__( :paramtype git_repos_validation_result: list[~azure.mgmt.appplatform.v2022_05_01_preview.models.ValidationMessages] """ - super(ConfigurationServiceGitPropertyValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.git_repos_validation_result = git_repos_validation_result -class ConfigurationServiceGitRepository(msrest.serialization.Model): +class ConfigurationServiceGitRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes """Git repository property payload for Application Configuration Service. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the repository. + :ivar name: Name of the repository. Required. :vartype name: str - :ivar patterns: Required. Collection of patterns of the repository. + :ivar patterns: Collection of patterns of the repository. Required. :vartype patterns: list[str] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str - :ivar label: Required. Label of the repository. + :ivar label: Label of the repository. Required. :vartype label: str :ivar search_paths: Searching path of the repository. :vartype search_paths: list[str] @@ -2863,24 +2668,24 @@ class ConfigurationServiceGitRepository(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'patterns': {'required': True}, - 'uri': {'required': True}, - 'label': {'required': True}, + "name": {"required": True}, + "patterns": {"required": True}, + "uri": {"required": True}, + "label": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'patterns': {'key': 'patterns', 'type': '[str]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "patterns": {"key": "patterns", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( @@ -2900,13 +2705,13 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of the repository. + :keyword name: Name of the repository. Required. :paramtype name: str - :keyword patterns: Required. Collection of patterns of the repository. + :keyword patterns: Collection of patterns of the repository. Required. :paramtype patterns: list[str] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str - :keyword label: Required. Label of the repository. + :keyword label: Label of the repository. Required. :paramtype label: str :keyword search_paths: Searching path of the repository. :paramtype search_paths: list[str] @@ -2923,7 +2728,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(ConfigurationServiceGitRepository, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.patterns = patterns self.uri = uri @@ -2937,7 +2742,7 @@ def __init__( self.strict_host_key_checking = strict_host_key_checking -class ConfigurationServiceInstance(msrest.serialization.Model): +class ConfigurationServiceInstance(_serialization.Model): """Collection of instances belong to the Application Configuration Service. Variables are only populated by the server, and will be ignored when sending a request. @@ -2949,33 +2754,29 @@ class ConfigurationServiceInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ConfigurationServiceInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class ConfigurationServiceProperties(msrest.serialization.Model): +class ConfigurationServiceProperties(_serialization.Model): """Application Configuration Service properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Application Configuration Service. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Application Configuration Service. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceProvisioningState :ivar resource_requests: The requested resource quantity for required CPU and Memory. @@ -2990,30 +2791,25 @@ class ConfigurationServiceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'resource_requests': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'ConfigurationServiceResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[ConfigurationServiceInstance]'}, - 'settings': {'key': 'settings', 'type': 'ConfigurationServiceSettings'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "ConfigurationServiceResourceRequests"}, + "instances": {"key": "instances", "type": "[ConfigurationServiceInstance]"}, + "settings": {"key": "settings", "type": "ConfigurationServiceSettings"}, } - def __init__( - self, - *, - settings: Optional["ConfigurationServiceSettings"] = None, - **kwargs - ): + def __init__(self, *, settings: Optional["_models.ConfigurationServiceSettings"] = None, **kwargs): """ :keyword settings: The settings of Application Configuration Service. :paramtype settings: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettings """ - super(ConfigurationServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.resource_requests = None self.instances = None @@ -3039,36 +2835,31 @@ class ConfigurationServiceResource(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': 'ConfigurationServiceProperties'}, + "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": "ConfigurationServiceProperties"}, } - def __init__( - self, - *, - properties: Optional["ConfigurationServiceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ConfigurationServiceProperties"] = None, **kwargs): """ :keyword properties: Application Configuration Service properties payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceProperties """ - super(ConfigurationServiceResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ConfigurationServiceResourceCollection(msrest.serialization.Model): +class ConfigurationServiceResourceCollection(_serialization.Model): """Object that includes an array of configuration service resources and a possible link for next set. :ivar value: Collection of configuration service resources. @@ -3080,14 +2871,14 @@ class ConfigurationServiceResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ConfigurationServiceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ConfigurationServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ConfigurationServiceResource"]] = None, + value: Optional[List["_models.ConfigurationServiceResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -3099,12 +2890,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ConfigurationServiceResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ConfigurationServiceResourceRequests(msrest.serialization.Model): +class ConfigurationServiceResourceRequests(_serialization.Model): """Resource request payload of Application Configuration Service. Variables are only populated by the server, and will be ignored when sending a request. @@ -3118,30 +2909,26 @@ class ConfigurationServiceResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, - 'instance_count': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ConfigurationServiceResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None self.instance_count = None -class ConfigurationServiceSettings(msrest.serialization.Model): +class ConfigurationServiceSettings(_serialization.Model): """The settings of Application Configuration Service. :ivar git_property: Property of git environment. @@ -3150,25 +2937,20 @@ class ConfigurationServiceSettings(msrest.serialization.Model): """ _attribute_map = { - 'git_property': {'key': 'gitProperty', 'type': 'ConfigurationServiceGitProperty'}, + "git_property": {"key": "gitProperty", "type": "ConfigurationServiceGitProperty"}, } - def __init__( - self, - *, - git_property: Optional["ConfigurationServiceGitProperty"] = None, - **kwargs - ): + def __init__(self, *, git_property: Optional["_models.ConfigurationServiceGitProperty"] = None, **kwargs): """ :keyword git_property: Property of git environment. :paramtype git_property: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceGitProperty """ - super(ConfigurationServiceSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property = git_property -class ConfigurationServiceSettingsValidateResult(msrest.serialization.Model): +class ConfigurationServiceSettingsValidateResult(_serialization.Model): """Validation result for configuration service settings. :ivar git_property_validation_result: Validation result for configuration service settings. @@ -3177,13 +2959,16 @@ class ConfigurationServiceSettingsValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'git_property_validation_result': {'key': 'gitPropertyValidationResult', 'type': 'ConfigurationServiceGitPropertyValidateResult'}, + "git_property_validation_result": { + "key": "gitPropertyValidationResult", + "type": "ConfigurationServiceGitPropertyValidateResult", + }, } def __init__( self, *, - git_property_validation_result: Optional["ConfigurationServiceGitPropertyValidateResult"] = None, + git_property_validation_result: Optional["_models.ConfigurationServiceGitPropertyValidateResult"] = None, **kwargs ): """ @@ -3191,11 +2976,11 @@ def __init__( :paramtype git_property_validation_result: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceGitPropertyValidateResult """ - super(ConfigurationServiceSettingsValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.git_property_validation_result = git_property_validation_result -class ContainerProbeSettings(msrest.serialization.Model): +class ContainerProbeSettings(_serialization.Model): """Container liveness and readiness probe settings. :ivar disable_probe: Indicates whether disable the liveness and readiness probe. @@ -3203,20 +2988,15 @@ class ContainerProbeSettings(msrest.serialization.Model): """ _attribute_map = { - 'disable_probe': {'key': 'disableProbe', 'type': 'bool'}, + "disable_probe": {"key": "disableProbe", "type": "bool"}, } - def __init__( - self, - *, - disable_probe: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, disable_probe: Optional[bool] = None, **kwargs): """ :keyword disable_probe: Indicates whether disable the liveness and readiness probe. :paramtype disable_probe: bool """ - super(ContainerProbeSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.disable_probe = disable_probe @@ -3227,7 +3007,7 @@ class ContentCertificateProperties(CertificateProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -3243,8 +3023,8 @@ class ContentCertificateProperties(CertificateProperties): :vartype subject_name: str :ivar dns_names: The domain list of certificate. :vartype dns_names: list[str] - :ivar provisioning_state: Provisioning state of the Certificate. Possible values include: - "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the Certificate. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResourceProvisioningState :ivar content: The content of uploaded certificate. @@ -3252,46 +3032,41 @@ class ContentCertificateProperties(CertificateProperties): """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'content': {'key': 'content', 'type': 'str'}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, + "provisioning_state": {"readonly": True}, } - def __init__( - self, - *, - content: Optional[str] = None, - **kwargs - ): + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "content": {"key": "content", "type": "str"}, + } + + def __init__(self, *, content: Optional[str] = None, **kwargs): """ :keyword content: The content of uploaded certificate. :paramtype content: str """ - super(ContentCertificateProperties, self).__init__(**kwargs) - self.type = 'ContentCertificate' # type: str + super().__init__(**kwargs) + self.type = "ContentCertificate" # type: str self.content = content -class CustomContainer(msrest.serialization.Model): +class CustomContainer(_serialization.Model): """Custom container payload. :ivar server: The name of the registry that contains the container image. @@ -3313,12 +3088,12 @@ class CustomContainer(msrest.serialization.Model): """ _attribute_map = { - 'server': {'key': 'server', 'type': 'str'}, - 'container_image': {'key': 'containerImage', 'type': 'str'}, - 'command': {'key': 'command', 'type': '[str]'}, - 'args': {'key': 'args', 'type': '[str]'}, - 'image_registry_credential': {'key': 'imageRegistryCredential', 'type': 'ImageRegistryCredential'}, - 'language_framework': {'key': 'languageFramework', 'type': 'str'}, + "server": {"key": "server", "type": "str"}, + "container_image": {"key": "containerImage", "type": "str"}, + "command": {"key": "command", "type": "[str]"}, + "args": {"key": "args", "type": "[str]"}, + "image_registry_credential": {"key": "imageRegistryCredential", "type": "ImageRegistryCredential"}, + "language_framework": {"key": "languageFramework", "type": "str"}, } def __init__( @@ -3328,7 +3103,7 @@ def __init__( container_image: Optional[str] = None, command: Optional[List[str]] = None, args: Optional[List[str]] = None, - image_registry_credential: Optional["ImageRegistryCredential"] = None, + image_registry_credential: Optional["_models.ImageRegistryCredential"] = None, language_framework: Optional[str] = None, **kwargs ): @@ -3350,7 +3125,7 @@ def __init__( :keyword language_framework: Language framework of the container image uploaded. :paramtype language_framework: str """ - super(CustomContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.server = server self.container_image = container_image self.command = command @@ -3364,7 +3139,7 @@ class CustomContainerUserSourceInfo(UserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -3373,21 +3148,17 @@ class CustomContainerUserSourceInfo(UserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'custom_container': {'key': 'customContainer', 'type': 'CustomContainer'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "custom_container": {"key": "customContainer", "type": "CustomContainer"}, } def __init__( - self, - *, - version: Optional[str] = None, - custom_container: Optional["CustomContainer"] = None, - **kwargs + self, *, version: Optional[str] = None, custom_container: Optional["_models.CustomContainer"] = None, **kwargs ): """ :keyword version: Version of the source. @@ -3395,12 +3166,12 @@ def __init__( :keyword custom_container: Custom container payload. :paramtype custom_container: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomContainer """ - super(CustomContainerUserSourceInfo, self).__init__(version=version, **kwargs) - self.type = 'Container' # type: str + super().__init__(version=version, **kwargs) + self.type = "Container" # type: str self.custom_container = custom_container -class CustomDomainProperties(msrest.serialization.Model): +class CustomDomainProperties(_serialization.Model): """Custom domain of app resource payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -3411,38 +3182,32 @@ class CustomDomainProperties(msrest.serialization.Model): :vartype app_name: str :ivar cert_name: The bound certificate name of domain. :vartype cert_name: str - :ivar provisioning_state: Provisioning state of the Domain. Possible values include: - "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the Domain. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResourceProvisioningState """ _validation = { - 'app_name': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "app_name": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'app_name': {'key': 'appName', 'type': 'str'}, - 'cert_name': {'key': 'certName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "app_name": {"key": "appName", "type": "str"}, + "cert_name": {"key": "certName", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - thumbprint: Optional[str] = None, - cert_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, thumbprint: Optional[str] = None, cert_name: Optional[str] = None, **kwargs): """ :keyword thumbprint: The thumbprint of bound certificate. :paramtype thumbprint: str :keyword cert_name: The bound certificate name of domain. :paramtype cert_name: str """ - super(CustomDomainProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = thumbprint self.app_name = None self.cert_name = cert_name @@ -3467,36 +3232,31 @@ class CustomDomainResource(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': 'CustomDomainProperties'}, + "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": "CustomDomainProperties"}, } - def __init__( - self, - *, - properties: Optional["CustomDomainProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CustomDomainProperties"] = None, **kwargs): """ :keyword properties: Properties of the custom domain resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainProperties """ - super(CustomDomainResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CustomDomainResourceCollection(msrest.serialization.Model): +class CustomDomainResourceCollection(_serialization.Model): """Collection compose of a custom domain resources list and a possible link for next page. :ivar value: The custom domain resources list. @@ -3506,16 +3266,12 @@ class CustomDomainResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CustomDomainResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CustomDomainResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The custom domain resources list. @@ -3523,43 +3279,38 @@ def __init__( :keyword next_link: The link to next page of custom domain list. :paramtype next_link: str """ - super(CustomDomainResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class CustomDomainValidatePayload(msrest.serialization.Model): +class CustomDomainValidatePayload(_serialization.Model): """Custom domain validate payload. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name to be validated. + :ivar name: Name to be validated. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Name to be validated. + :keyword name: Name to be validated. Required. :paramtype name: str """ - super(CustomDomainValidatePayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CustomDomainValidateResult(msrest.serialization.Model): +class CustomDomainValidateResult(_serialization.Model): """Validation result for custom domain. :ivar is_valid: Indicates if domain name is valid. @@ -3569,29 +3320,23 @@ class CustomDomainValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'message': {'key': 'message', 'type': 'str'}, + "is_valid": {"key": "isValid", "type": "bool"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - is_valid: Optional[bool] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, is_valid: Optional[bool] = None, message: Optional[str] = None, **kwargs): """ :keyword is_valid: Indicates if domain name is valid. :paramtype is_valid: bool :keyword message: Message of why domain name is invalid. :paramtype message: str """ - super(CustomDomainValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_valid = is_valid self.message = message -class CustomPersistentDiskResource(msrest.serialization.Model): +class CustomPersistentDiskResource(_serialization.Model): """Custom persistent disk resource payload. All required parameters must be populated in order to send to Azure. @@ -3600,24 +3345,27 @@ class CustomPersistentDiskResource(msrest.serialization.Model): payload. :vartype custom_persistent_disk_properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomPersistentDiskProperties - :ivar storage_id: Required. The resource id of Azure Spring Apps Storage resource. + :ivar storage_id: The resource id of Azure Spring Apps Storage resource. Required. :vartype storage_id: str """ _validation = { - 'storage_id': {'required': True}, + "storage_id": {"required": True}, } _attribute_map = { - 'custom_persistent_disk_properties': {'key': 'customPersistentDiskProperties', 'type': 'CustomPersistentDiskProperties'}, - 'storage_id': {'key': 'storageId', 'type': 'str'}, + "custom_persistent_disk_properties": { + "key": "customPersistentDiskProperties", + "type": "CustomPersistentDiskProperties", + }, + "storage_id": {"key": "storageId", "type": "str"}, } def __init__( self, *, storage_id: str, - custom_persistent_disk_properties: Optional["CustomPersistentDiskProperties"] = None, + custom_persistent_disk_properties: Optional["_models.CustomPersistentDiskProperties"] = None, **kwargs ): """ @@ -3625,15 +3373,15 @@ def __init__( payload. :paramtype custom_persistent_disk_properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomPersistentDiskProperties - :keyword storage_id: Required. The resource id of Azure Spring Apps Storage resource. + :keyword storage_id: The resource id of Azure Spring Apps Storage resource. Required. :paramtype storage_id: str """ - super(CustomPersistentDiskResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.custom_persistent_disk_properties = custom_persistent_disk_properties self.storage_id = storage_id -class DeploymentInstance(msrest.serialization.Model): +class DeploymentInstance(_serialization.Model): """Deployment instance payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -3653,30 +3401,26 @@ class DeploymentInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, - 'reason': {'readonly': True}, - 'discovery_status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'zone': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, + "reason": {"readonly": True}, + "discovery_status": {"readonly": True}, + "start_time": {"readonly": True}, + "zone": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'discovery_status': {'key': 'discoveryStatus', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'zone': {'key': 'zone', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "discovery_status": {"key": "discoveryStatus", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, + "zone": {"key": "zone", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None self.reason = None @@ -3706,26 +3450,26 @@ class DeploymentResource(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': 'DeploymentResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "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": "DeploymentResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( self, *, - properties: Optional["DeploymentResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.DeploymentResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -3735,12 +3479,12 @@ def __init__( :keyword sku: Sku of the Deployment resource. :paramtype sku: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Sku """ - super(DeploymentResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.sku = sku -class DeploymentResourceCollection(msrest.serialization.Model): +class DeploymentResourceCollection(_serialization.Model): """Object that includes an array of App resources and a possible link for next set. :ivar value: Collection of Deployment resources. @@ -3751,16 +3495,12 @@ class DeploymentResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["DeploymentResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.DeploymentResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Deployment resources. @@ -3769,12 +3509,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(DeploymentResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class DeploymentResourceProperties(msrest.serialization.Model): +class DeploymentResourceProperties(_serialization.Model): """Deployment resource properties payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -3784,11 +3524,11 @@ class DeploymentResourceProperties(msrest.serialization.Model): :ivar deployment_settings: Deployment settings of the Deployment. :vartype deployment_settings: ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentSettings - :ivar provisioning_state: Provisioning state of the Deployment. Possible values include: - "Creating", "Updating", "Succeeded", "Failed". + :ivar provisioning_state: Provisioning state of the Deployment. Known values are: "Creating", + "Updating", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResourceProvisioningState - :ivar status: Status of the Deployment. Possible values include: "Stopped", "Running". + :ivar status: Status of the Deployment. Known values are: "Stopped" and "Running". :vartype status: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResourceStatus :ivar active: Indicates whether the Deployment is active. @@ -3798,25 +3538,25 @@ class DeploymentResourceProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'UserSourceInfo'}, - 'deployment_settings': {'key': 'deploymentSettings', 'type': 'DeploymentSettings'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'active': {'key': 'active', 'type': 'bool'}, - 'instances': {'key': 'instances', 'type': '[DeploymentInstance]'}, + "source": {"key": "source", "type": "UserSourceInfo"}, + "deployment_settings": {"key": "deploymentSettings", "type": "DeploymentSettings"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "active": {"key": "active", "type": "bool"}, + "instances": {"key": "instances", "type": "[DeploymentInstance]"}, } def __init__( self, *, - source: Optional["UserSourceInfo"] = None, - deployment_settings: Optional["DeploymentSettings"] = None, + source: Optional["_models.UserSourceInfo"] = None, + deployment_settings: Optional["_models.DeploymentSettings"] = None, active: Optional[bool] = None, **kwargs ): @@ -3829,7 +3569,7 @@ def __init__( :keyword active: Indicates whether the Deployment is active. :paramtype active: bool """ - super(DeploymentResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.deployment_settings = deployment_settings self.provisioning_state = None @@ -3838,7 +3578,7 @@ def __init__( self.instances = None -class DeploymentSettings(msrest.serialization.Model): +class DeploymentSettings(_serialization.Model): """Deployment settings payload. :ivar resource_requests: The requested resource quantity for required CPU and Memory. It is @@ -3848,7 +3588,7 @@ class DeploymentSettings(msrest.serialization.Model): :ivar environment_variables: Collection of environment variables. :vartype environment_variables: dict[str, str] :ivar addon_configs: Collection of addons. - :vartype addon_configs: dict[str, dict[str, any]] + :vartype addon_configs: dict[str, dict[str, JSON]] :ivar liveness_probe: Periodic probe of App Instance liveness. App Instance will be restarted if the probe fails. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. @@ -3879,27 +3619,27 @@ class DeploymentSettings(msrest.serialization.Model): """ _attribute_map = { - 'resource_requests': {'key': 'resourceRequests', 'type': 'ResourceRequests'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '{str}'}, - 'addon_configs': {'key': 'addonConfigs', 'type': '{{object}}'}, - 'liveness_probe': {'key': 'livenessProbe', 'type': 'Probe'}, - 'readiness_probe': {'key': 'readinessProbe', 'type': 'Probe'}, - 'startup_probe': {'key': 'startupProbe', 'type': 'Probe'}, - 'termination_grace_period_seconds': {'key': 'terminationGracePeriodSeconds', 'type': 'int'}, - 'container_probe_settings': {'key': 'containerProbeSettings', 'type': 'ContainerProbeSettings'}, + "resource_requests": {"key": "resourceRequests", "type": "ResourceRequests"}, + "environment_variables": {"key": "environmentVariables", "type": "{str}"}, + "addon_configs": {"key": "addonConfigs", "type": "{{object}}"}, + "liveness_probe": {"key": "livenessProbe", "type": "Probe"}, + "readiness_probe": {"key": "readinessProbe", "type": "Probe"}, + "startup_probe": {"key": "startupProbe", "type": "Probe"}, + "termination_grace_period_seconds": {"key": "terminationGracePeriodSeconds", "type": "int"}, + "container_probe_settings": {"key": "containerProbeSettings", "type": "ContainerProbeSettings"}, } def __init__( self, *, - resource_requests: Optional["ResourceRequests"] = None, + resource_requests: Optional["_models.ResourceRequests"] = None, environment_variables: Optional[Dict[str, str]] = None, - addon_configs: Optional[Dict[str, Dict[str, Any]]] = None, - liveness_probe: Optional["Probe"] = None, - readiness_probe: Optional["Probe"] = None, - startup_probe: Optional["Probe"] = None, - termination_grace_period_seconds: Optional[int] = 90, - container_probe_settings: Optional["ContainerProbeSettings"] = None, + addon_configs: Optional[Dict[str, Dict[str, JSON]]] = None, + liveness_probe: Optional["_models.Probe"] = None, + readiness_probe: Optional["_models.Probe"] = None, + startup_probe: Optional["_models.Probe"] = None, + termination_grace_period_seconds: int = 90, + container_probe_settings: Optional["_models.ContainerProbeSettings"] = None, **kwargs ): """ @@ -3911,7 +3651,7 @@ def __init__( :keyword environment_variables: Collection of environment variables. :paramtype environment_variables: dict[str, str] :keyword addon_configs: Collection of addons. - :paramtype addon_configs: dict[str, dict[str, any]] + :paramtype addon_configs: dict[str, dict[str, JSON]] :keyword liveness_probe: Periodic probe of App Instance liveness. App Instance will be restarted if the probe fails. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. @@ -3940,7 +3680,7 @@ def __init__( :paramtype container_probe_settings: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ContainerProbeSettings """ - super(DeploymentSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_requests = resource_requests self.environment_variables = environment_variables self.addon_configs = addon_configs @@ -3951,7 +3691,7 @@ def __init__( self.container_probe_settings = container_probe_settings -class DiagnosticParameters(msrest.serialization.Model): +class DiagnosticParameters(_serialization.Model): """Diagnostic parameters of diagnostic operations. :ivar app_instance: App instance name. @@ -3963,9 +3703,9 @@ class DiagnosticParameters(msrest.serialization.Model): """ _attribute_map = { - 'app_instance': {'key': 'appInstance', 'type': 'str'}, - 'file_path': {'key': 'filePath', 'type': 'str'}, - 'duration': {'key': 'duration', 'type': 'str'}, + "app_instance": {"key": "appInstance", "type": "str"}, + "file_path": {"key": "filePath", "type": "str"}, + "duration": {"key": "duration", "type": "str"}, } def __init__( @@ -3984,13 +3724,13 @@ def __init__( :keyword duration: Duration of your JFR. 1 min can be represented by 1m or 60s. :paramtype duration: str """ - super(DiagnosticParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.app_instance = app_instance self.file_path = file_path self.duration = duration -class Error(msrest.serialization.Model): +class Error(_serialization.Model): """The error code compose of code and message. :ivar code: The code of error. @@ -4000,60 +3740,50 @@ class Error(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: The code of error. :paramtype code: str :keyword message: The message of error. :paramtype message: str """ - super(Error, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ProbeAction(msrest.serialization.Model): +class ProbeAction(_serialization.Model): """The action of the probe. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ExecAction, HTTPGetAction, TCPSocketAction. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ExecAction, HTTPGetAction, TCPSocketAction All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the action to take to perform the health check.Constant - filled by server. Possible values include: "HTTPGetAction", "TCPSocketAction", "ExecAction". + :ivar type: The type of the action to take to perform the health check. Required. Known values + are: "HTTPGetAction", "TCPSocketAction", and "ExecAction". :vartype type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ProbeActionType """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, } _subtype_map = { - 'type': {'ExecAction': 'ExecAction', 'HTTPGetAction': 'HTTPGetAction', 'TCPSocketAction': 'TCPSocketAction'} + "type": {"ExecAction": "ExecAction", "HTTPGetAction": "HTTPGetAction", "TCPSocketAction": "TCPSocketAction"} } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProbeAction, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None # type: Optional[str] @@ -4062,8 +3792,8 @@ class ExecAction(ProbeAction): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the action to take to perform the health check.Constant - filled by server. Possible values include: "HTTPGetAction", "TCPSocketAction", "ExecAction". + :ivar type: The type of the action to take to perform the health check. Required. Known values + are: "HTTPGetAction", "TCPSocketAction", and "ExecAction". :vartype type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ProbeActionType :ivar command: Command is the command line to execute inside the container, the working directory for the command is root ('/') in the container's filesystem. The command is not run @@ -4074,20 +3804,15 @@ class ExecAction(ProbeAction): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'command': {'key': 'command', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "command": {"key": "command", "type": "[str]"}, } - def __init__( - self, - *, - command: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, command: Optional[List[str]] = None, **kwargs): """ :keyword command: Command is the command line to execute inside the container, the working directory for the command is root ('/') in the container's filesystem. The command is not run @@ -4096,12 +3821,12 @@ def __init__( non-zero is unhealthy. :paramtype command: list[str] """ - super(ExecAction, self).__init__(**kwargs) - self.type = 'ExecAction' # type: str + super().__init__(**kwargs) + self.type = "ExecAction" # type: str self.command = command -class GatewayApiMetadataProperties(msrest.serialization.Model): +class GatewayApiMetadataProperties(_serialization.Model): """API metadata property for Spring Cloud Gateway. :ivar title: Title describing the context of the APIs available on the Gateway instance @@ -4120,11 +3845,11 @@ class GatewayApiMetadataProperties(msrest.serialization.Model): """ _attribute_map = { - 'title': {'key': 'title', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'documentation': {'key': 'documentation', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'server_url': {'key': 'serverUrl', 'type': 'str'}, + "title": {"key": "title", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "documentation": {"key": "documentation", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "server_url": {"key": "serverUrl", "type": "str"}, } def __init__( @@ -4154,7 +3879,7 @@ def __init__( instance. :paramtype server_url: str """ - super(GatewayApiMetadataProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.title = title self.description = description self.documentation = documentation @@ -4162,7 +3887,7 @@ def __init__( self.server_url = server_url -class GatewayApiRoute(msrest.serialization.Model): +class GatewayApiRoute(_serialization.Model): """API route config of the Spring Cloud Gateway. :ivar title: A title, will be applied to methods in the generated OpenAPI documentation. @@ -4186,21 +3911,21 @@ class GatewayApiRoute(msrest.serialization.Model): :vartype filters: list[str] :ivar order: Route processing order. :vartype order: int - :ivar tags: A set of tags. Classification tags, will be applied to methods in the generated - OpenAPI documentation. + :ivar tags: Classification tags, will be applied to methods in the generated OpenAPI + documentation. :vartype tags: list[str] """ _attribute_map = { - 'title': {'key': 'title', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'sso_enabled': {'key': 'ssoEnabled', 'type': 'bool'}, - 'token_relay': {'key': 'tokenRelay', 'type': 'bool'}, - 'predicates': {'key': 'predicates', 'type': '[str]'}, - 'filters': {'key': 'filters', 'type': '[str]'}, - 'order': {'key': 'order', 'type': 'int'}, - 'tags': {'key': 'tags', 'type': '[str]'}, + "title": {"key": "title", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "sso_enabled": {"key": "ssoEnabled", "type": "bool"}, + "token_relay": {"key": "tokenRelay", "type": "bool"}, + "predicates": {"key": "predicates", "type": "[str]"}, + "filters": {"key": "filters", "type": "[str]"}, + "order": {"key": "order", "type": "int"}, + "tags": {"key": "tags", "type": "[str]"}, } def __init__( @@ -4239,11 +3964,11 @@ def __init__( :paramtype filters: list[str] :keyword order: Route processing order. :paramtype order: int - :keyword tags: A set of tags. Classification tags, will be applied to methods in the generated - OpenAPI documentation. + :keyword tags: Classification tags, will be applied to methods in the generated OpenAPI + documentation. :paramtype tags: list[str] """ - super(GatewayApiRoute, self).__init__(**kwargs) + super().__init__(**kwargs) self.title = title self.description = description self.uri = uri @@ -4255,7 +3980,7 @@ def __init__( self.tags = tags -class GatewayCorsProperties(msrest.serialization.Model): +class GatewayCorsProperties(_serialization.Model): """Cross-Origin Resource Sharing property. :ivar allowed_origins: Allowed origins to make cross-site requests. The special value ``*`` @@ -4278,12 +4003,12 @@ class GatewayCorsProperties(msrest.serialization.Model): """ _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, - 'max_age': {'key': 'maxAge', 'type': 'int'}, - 'allow_credentials': {'key': 'allowCredentials', 'type': 'bool'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, + "max_age": {"key": "maxAge", "type": "int"}, + "allow_credentials": {"key": "allowCredentials", "type": "bool"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, } def __init__( @@ -4316,7 +4041,7 @@ def __init__( :keyword exposed_headers: HTTP response headers to expose for cross-site requests. :paramtype exposed_headers: list[str] """ - super(GatewayCorsProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.allowed_headers = allowed_headers @@ -4325,7 +4050,7 @@ def __init__( self.exposed_headers = exposed_headers -class GatewayCustomDomainProperties(msrest.serialization.Model): +class GatewayCustomDomainProperties(_serialization.Model): """The properties of custom domain for Spring Cloud Gateway. :ivar thumbprint: The thumbprint of bound certificate. @@ -4333,20 +4058,15 @@ class GatewayCustomDomainProperties(msrest.serialization.Model): """ _attribute_map = { - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, + "thumbprint": {"key": "thumbprint", "type": "str"}, } - def __init__( - self, - *, - thumbprint: Optional[str] = None, - **kwargs - ): + def __init__(self, *, thumbprint: Optional[str] = None, **kwargs): """ :keyword thumbprint: The thumbprint of bound certificate. :paramtype thumbprint: str """ - super(GatewayCustomDomainProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.thumbprint = thumbprint @@ -4369,36 +4089,31 @@ class GatewayCustomDomainResource(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': 'GatewayCustomDomainProperties'}, + "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": "GatewayCustomDomainProperties"}, } - def __init__( - self, - *, - properties: Optional["GatewayCustomDomainProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.GatewayCustomDomainProperties"] = None, **kwargs): """ :keyword properties: The properties of custom domain for Spring Cloud Gateway. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainProperties """ - super(GatewayCustomDomainResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class GatewayCustomDomainResourceCollection(msrest.serialization.Model): +class GatewayCustomDomainResourceCollection(_serialization.Model): """Object that includes an array of Spring Cloud Gateway custom domain resources and a possible link for next set. :ivar value: Collection of Spring Cloud Gateway custom domain resources. @@ -4410,14 +4125,14 @@ class GatewayCustomDomainResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayCustomDomainResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GatewayCustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["GatewayCustomDomainResource"]] = None, + value: Optional[List["_models.GatewayCustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -4429,12 +4144,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(GatewayCustomDomainResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class GatewayInstance(msrest.serialization.Model): +class GatewayInstance(_serialization.Model): """Collection of instances belong to the Spring Cloud Gateway. Variables are only populated by the server, and will be ignored when sending a request. @@ -4446,27 +4161,23 @@ class GatewayInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GatewayInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class GatewayOperatorProperties(msrest.serialization.Model): +class GatewayOperatorProperties(_serialization.Model): """Properties of the Spring Cloud Gateway Operator. Variables are only populated by the server, and will be ignored when sending a request. @@ -4479,27 +4190,23 @@ class GatewayOperatorProperties(msrest.serialization.Model): """ _validation = { - 'resource_requests': {'readonly': True}, - 'instances': {'readonly': True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'resource_requests': {'key': 'resourceRequests', 'type': 'GatewayOperatorResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[GatewayInstance]'}, + "resource_requests": {"key": "resourceRequests", "type": "GatewayOperatorResourceRequests"}, + "instances": {"key": "instances", "type": "[GatewayInstance]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GatewayOperatorProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_requests = None self.instances = None -class GatewayOperatorResourceRequests(msrest.serialization.Model): +class GatewayOperatorResourceRequests(_serialization.Model): """Properties of the Spring Cloud Gateway Operator. Variables are only populated by the server, and will be ignored when sending a request. @@ -4513,36 +4220,32 @@ class GatewayOperatorResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, - 'instance_count': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(GatewayOperatorResourceRequests, self).__init__(**kwargs) + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None self.instance_count = None -class GatewayProperties(msrest.serialization.Model): +class GatewayProperties(_serialization.Model): """Spring Cloud Gateway properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Spring Cloud Gateway. Possible values include: - "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Spring Cloud Gateway. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayProvisioningState :ivar public: Indicates whether the Spring Cloud Gateway exposes endpoint. @@ -4570,34 +4273,34 @@ class GatewayProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'url': {'readonly': True}, - 'instances': {'readonly': True}, - 'operator_properties': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "url": {"readonly": True}, + "instances": {"readonly": True}, + "operator_properties": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'public': {'key': 'public', 'type': 'bool'}, - 'url': {'key': 'url', 'type': 'str'}, - 'https_only': {'key': 'httpsOnly', 'type': 'bool'}, - 'sso_properties': {'key': 'ssoProperties', 'type': 'SsoProperties'}, - 'api_metadata_properties': {'key': 'apiMetadataProperties', 'type': 'GatewayApiMetadataProperties'}, - 'cors_properties': {'key': 'corsProperties', 'type': 'GatewayCorsProperties'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'GatewayResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[GatewayInstance]'}, - 'operator_properties': {'key': 'operatorProperties', 'type': 'GatewayOperatorProperties'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "sso_properties": {"key": "ssoProperties", "type": "SsoProperties"}, + "api_metadata_properties": {"key": "apiMetadataProperties", "type": "GatewayApiMetadataProperties"}, + "cors_properties": {"key": "corsProperties", "type": "GatewayCorsProperties"}, + "resource_requests": {"key": "resourceRequests", "type": "GatewayResourceRequests"}, + "instances": {"key": "instances", "type": "[GatewayInstance]"}, + "operator_properties": {"key": "operatorProperties", "type": "GatewayOperatorProperties"}, } def __init__( self, *, - public: Optional[bool] = False, - https_only: Optional[bool] = False, - sso_properties: Optional["SsoProperties"] = None, - api_metadata_properties: Optional["GatewayApiMetadataProperties"] = None, - cors_properties: Optional["GatewayCorsProperties"] = None, - resource_requests: Optional["GatewayResourceRequests"] = None, + public: bool = False, + https_only: bool = False, + sso_properties: Optional["_models.SsoProperties"] = None, + api_metadata_properties: Optional["_models.GatewayApiMetadataProperties"] = None, + cors_properties: Optional["_models.GatewayCorsProperties"] = None, + resource_requests: Optional["_models.GatewayResourceRequests"] = None, **kwargs ): """ @@ -4617,7 +4320,7 @@ def __init__( :paramtype resource_requests: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResourceRequests """ - super(GatewayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.public = public self.url = None @@ -4650,27 +4353,23 @@ class GatewayResource(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': 'GatewayProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "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": "GatewayProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( - self, - *, - properties: Optional["GatewayProperties"] = None, - sku: Optional["Sku"] = None, - **kwargs + self, *, properties: Optional["_models.GatewayProperties"] = None, sku: Optional["_models.Sku"] = None, **kwargs ): """ :keyword properties: Spring Cloud Gateway properties payload. @@ -4678,12 +4377,12 @@ def __init__( :keyword sku: Sku of the Spring Cloud Gateway resource. :paramtype sku: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Sku """ - super(GatewayResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.sku = sku -class GatewayResourceCollection(msrest.serialization.Model): +class GatewayResourceCollection(_serialization.Model): """Object that includes an array of gateway resources and a possible link for next set. :ivar value: Collection of gateway resources. @@ -4694,16 +4393,12 @@ class GatewayResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GatewayResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["GatewayResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.GatewayResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of gateway resources. @@ -4712,12 +4407,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(GatewayResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class GatewayResourceRequests(msrest.serialization.Model): +class GatewayResourceRequests(_serialization.Model): """Resource request payload of Spring Cloud Gateway. :ivar cpu: Cpu allocated to each Spring Cloud Gateway instance. @@ -4727,29 +4422,23 @@ class GatewayResourceRequests(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - *, - cpu: Optional[str] = None, - memory: Optional[str] = None, - **kwargs - ): + def __init__(self, *, cpu: str = "1", memory: str = "2Gi", **kwargs): """ :keyword cpu: Cpu allocated to each Spring Cloud Gateway instance. :paramtype cpu: str :keyword memory: Memory allocated to each Spring Cloud Gateway instance. :paramtype memory: str """ - super(GatewayResourceRequests, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory = memory -class GatewayRouteConfigOpenApiProperties(msrest.serialization.Model): +class GatewayRouteConfigOpenApiProperties(_serialization.Model): """OpenAPI properties of Spring Cloud Gateway route config. :ivar uri: The URI of OpenAPI specification. @@ -4757,30 +4446,25 @@ class GatewayRouteConfigOpenApiProperties(msrest.serialization.Model): """ _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, } - def __init__( - self, - *, - uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: Optional[str] = None, **kwargs): """ :keyword uri: The URI of OpenAPI specification. :paramtype uri: str """ - super(GatewayRouteConfigOpenApiProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri -class GatewayRouteConfigProperties(msrest.serialization.Model): +class GatewayRouteConfigProperties(_serialization.Model): """API route config of the Spring Cloud Gateway. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Spring Cloud Gateway route config. Possible values - include: "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Spring Cloud Gateway route config. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayProvisioningState :ivar app_resource_id: The resource Id of the Azure Spring Apps app, required unless route @@ -4795,22 +4479,22 @@ class GatewayRouteConfigProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'app_resource_id': {'key': 'appResourceId', 'type': 'str'}, - 'open_api': {'key': 'openApi', 'type': 'GatewayRouteConfigOpenApiProperties'}, - 'routes': {'key': 'routes', 'type': '[GatewayApiRoute]'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "app_resource_id": {"key": "appResourceId", "type": "str"}, + "open_api": {"key": "openApi", "type": "GatewayRouteConfigOpenApiProperties"}, + "routes": {"key": "routes", "type": "[GatewayApiRoute]"}, } def __init__( self, *, app_resource_id: Optional[str] = None, - open_api: Optional["GatewayRouteConfigOpenApiProperties"] = None, - routes: Optional[List["GatewayApiRoute"]] = None, + open_api: Optional["_models.GatewayRouteConfigOpenApiProperties"] = None, + routes: Optional[List["_models.GatewayApiRoute"]] = None, **kwargs ): """ @@ -4824,7 +4508,7 @@ def __init__( ``uri``\ , ``ssoEnabled``\ , ``predicates``\ , ``filters``. :paramtype routes: list[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayApiRoute] """ - super(GatewayRouteConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.app_resource_id = app_resource_id self.open_api = open_api @@ -4850,36 +4534,31 @@ class GatewayRouteConfigResource(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': 'GatewayRouteConfigProperties'}, + "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": "GatewayRouteConfigProperties"}, } - def __init__( - self, - *, - properties: Optional["GatewayRouteConfigProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.GatewayRouteConfigProperties"] = None, **kwargs): """ :keyword properties: API route config of the Spring Cloud Gateway. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigProperties """ - super(GatewayRouteConfigResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class GatewayRouteConfigResourceCollection(msrest.serialization.Model): +class GatewayRouteConfigResourceCollection(_serialization.Model): """Object that includes an array of Spring Cloud Gateway route config resources and a possible link for next set. :ivar value: Collection of Spring Cloud Gateway route config resources. @@ -4891,14 +4570,14 @@ class GatewayRouteConfigResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayRouteConfigResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GatewayRouteConfigResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["GatewayRouteConfigResource"]] = None, + value: Optional[List["_models.GatewayRouteConfigResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -4910,21 +4589,21 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(GatewayRouteConfigResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class GitPatternRepository(msrest.serialization.Model): +class GitPatternRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes """Git repository property payload for config server. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the repository. + :ivar name: Name of the repository. Required. :vartype name: str :ivar pattern: Collection of pattern of the repository. :vartype pattern: list[str] - :ivar uri: Required. URI of the repository. + :ivar uri: URI of the repository. Required. :vartype uri: str :ivar label: Label of the repository. :vartype label: str @@ -4945,22 +4624,22 @@ class GitPatternRepository(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'uri': {'required': True}, + "name": {"required": True}, + "uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'pattern': {'key': 'pattern', 'type': '[str]'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'search_paths': {'key': 'searchPaths', 'type': '[str]'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'host_key': {'key': 'hostKey', 'type': 'str'}, - 'host_key_algorithm': {'key': 'hostKeyAlgorithm', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'strict_host_key_checking': {'key': 'strictHostKeyChecking', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "pattern": {"key": "pattern", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, } def __init__( @@ -4980,11 +4659,11 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of the repository. + :keyword name: Name of the repository. Required. :paramtype name: str :keyword pattern: Collection of pattern of the repository. :paramtype pattern: list[str] - :keyword uri: Required. URI of the repository. + :keyword uri: URI of the repository. Required. :paramtype uri: str :keyword label: Label of the repository. :paramtype label: str @@ -5003,7 +4682,7 @@ def __init__( :keyword strict_host_key_checking: Strict host key checking or not. :paramtype strict_host_key_checking: bool """ - super(GitPatternRepository, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.pattern = pattern self.uri = uri @@ -5022,59 +4701,55 @@ class HTTPGetAction(ProbeAction): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the action to take to perform the health check.Constant - filled by server. Possible values include: "HTTPGetAction", "TCPSocketAction", "ExecAction". + :ivar type: The type of the action to take to perform the health check. Required. Known values + are: "HTTPGetAction", "TCPSocketAction", and "ExecAction". :vartype type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ProbeActionType :ivar path: Path to access on the HTTP server. :vartype path: str :ivar scheme: Scheme to use for connecting to the host. Defaults to HTTP. - + Possible enum values: - - + + * ``"HTTP"`` means that the scheme used will be http:// - * ``"HTTPS"`` means that the scheme used will be https://. Possible values include: "HTTP", + * ``"HTTPS"`` means that the scheme used will be https://. Known values are: "HTTP" and "HTTPS". :vartype scheme: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.HTTPSchemeType """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'path': {'key': 'path', 'type': 'str'}, - 'scheme': {'key': 'scheme', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "path": {"key": "path", "type": "str"}, + "scheme": {"key": "scheme", "type": "str"}, } def __init__( - self, - *, - path: Optional[str] = None, - scheme: Optional[Union[str, "HTTPSchemeType"]] = None, - **kwargs + self, *, path: Optional[str] = None, scheme: Optional[Union[str, "_models.HTTPSchemeType"]] = None, **kwargs ): """ :keyword path: Path to access on the HTTP server. :paramtype path: str :keyword scheme: Scheme to use for connecting to the host. Defaults to HTTP. - + Possible enum values: - - + + * ``"HTTP"`` means that the scheme used will be http:// - * ``"HTTPS"`` means that the scheme used will be https://. Possible values include: "HTTP", + * ``"HTTPS"`` means that the scheme used will be https://. Known values are: "HTTP" and "HTTPS". :paramtype scheme: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.HTTPSchemeType """ - super(HTTPGetAction, self).__init__(**kwargs) - self.type = 'HTTPGetAction' # type: str + super().__init__(**kwargs) + self.type = "HTTPGetAction" # type: str self.path = path self.scheme = scheme -class ImageRegistryCredential(msrest.serialization.Model): +class ImageRegistryCredential(_serialization.Model): """Credential of the image registry. :ivar username: The username of the image registry credential. @@ -5084,29 +4759,23 @@ class ImageRegistryCredential(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - username: Optional[str] = None, - password: Optional[str] = None, - **kwargs - ): + def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs): """ :keyword username: The username of the image registry credential. :paramtype username: str :keyword password: The password of the image registry credential. :paramtype password: str """ - super(ImageRegistryCredential, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.password = password -class IngressConfig(msrest.serialization.Model): +class IngressConfig(_serialization.Model): """Ingress configuration payload for Azure Spring Apps resource. :ivar read_timeout_in_seconds: Ingress read time out in seconds. @@ -5114,32 +4783,27 @@ class IngressConfig(msrest.serialization.Model): """ _attribute_map = { - 'read_timeout_in_seconds': {'key': 'readTimeoutInSeconds', 'type': 'int'}, + "read_timeout_in_seconds": {"key": "readTimeoutInSeconds", "type": "int"}, } - def __init__( - self, - *, - read_timeout_in_seconds: Optional[int] = None, - **kwargs - ): + def __init__(self, *, read_timeout_in_seconds: Optional[int] = None, **kwargs): """ :keyword read_timeout_in_seconds: Ingress read time out in seconds. :paramtype read_timeout_in_seconds: int """ - super(IngressConfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.read_timeout_in_seconds = read_timeout_in_seconds class UploadedUserSourceInfo(UserSourceInfo): """Source with uploaded location. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: JarUploadedUserSourceInfo, NetCoreZipUploadedUserSourceInfo, SourceUploadedUserSourceInfo. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + JarUploadedUserSourceInfo, NetCoreZipUploadedUserSourceInfo, SourceUploadedUserSourceInfo All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -5148,34 +4812,32 @@ class UploadedUserSourceInfo(UserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, } _subtype_map = { - 'type': {'Jar': 'JarUploadedUserSourceInfo', 'NetCoreZip': 'NetCoreZipUploadedUserSourceInfo', 'Source': 'SourceUploadedUserSourceInfo'} + "type": { + "Jar": "JarUploadedUserSourceInfo", + "NetCoreZip": "NetCoreZipUploadedUserSourceInfo", + "Source": "SourceUploadedUserSourceInfo", + } } - def __init__( - self, - *, - version: Optional[str] = None, - relative_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, version: Optional[str] = None, relative_path: Optional[str] = None, **kwargs): """ :keyword version: Version of the source. :paramtype version: str :keyword relative_path: Relative path of the storage which stores the source. :paramtype relative_path: str """ - super(UploadedUserSourceInfo, self).__init__(version=version, **kwargs) - self.type = 'UploadedUserSourceInfo' # type: str + super().__init__(version=version, **kwargs) + self.type = "UploadedUserSourceInfo" # type: str self.relative_path = relative_path @@ -5184,7 +4846,7 @@ class JarUploadedUserSourceInfo(UploadedUserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -5197,15 +4859,15 @@ class JarUploadedUserSourceInfo(UploadedUserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, - 'jvm_options': {'key': 'jvmOptions', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, + "jvm_options": {"key": "jvmOptions", "type": "str"}, } def __init__( @@ -5227,20 +4889,20 @@ def __init__( :keyword jvm_options: JVM parameter. :paramtype jvm_options: str """ - super(JarUploadedUserSourceInfo, self).__init__(version=version, relative_path=relative_path, **kwargs) - self.type = 'Jar' # type: str + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "Jar" # type: str self.runtime_version = runtime_version self.jvm_options = jvm_options -class KeyVaultCertificateProperties(CertificateProperties): +class KeyVaultCertificateProperties(CertificateProperties): # pylint: disable=too-many-instance-attributes """Properties of certificate imported from key vault. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the certificate source.Constant filled by server. + :ivar type: The type of the certificate source. Required. :vartype type: str :ivar thumbprint: The thumbprint of certificate. :vartype thumbprint: str @@ -5256,13 +4918,13 @@ class KeyVaultCertificateProperties(CertificateProperties): :vartype subject_name: str :ivar dns_names: The domain list of certificate. :vartype dns_names: list[str] - :ivar provisioning_state: Provisioning state of the Certificate. Possible values include: - "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: Provisioning state of the Certificate. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResourceProvisioningState - :ivar vault_uri: Required. The vault uri of user key vault. + :ivar vault_uri: The vault uri of user key vault. Required. :vartype vault_uri: str - :ivar key_vault_cert_name: Required. The certificate name of key vault. + :ivar key_vault_cert_name: The certificate name of key vault. Required. :vartype key_vault_cert_name: str :ivar cert_version: The certificate version of key vault. :vartype cert_version: str @@ -5272,33 +4934,33 @@ class KeyVaultCertificateProperties(CertificateProperties): """ _validation = { - 'type': {'required': True}, - 'thumbprint': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issued_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'activate_date': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'dns_names': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'vault_uri': {'required': True}, - 'key_vault_cert_name': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issued_date': {'key': 'issuedDate', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'str'}, - 'activate_date': {'key': 'activateDate', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'dns_names': {'key': 'dnsNames', 'type': '[str]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'vault_uri': {'key': 'vaultUri', 'type': 'str'}, - 'key_vault_cert_name': {'key': 'keyVaultCertName', 'type': 'str'}, - 'cert_version': {'key': 'certVersion', 'type': 'str'}, - 'exclude_private_key': {'key': 'excludePrivateKey', 'type': 'bool'}, + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "vault_uri": {"required": True}, + "key_vault_cert_name": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "vault_uri": {"key": "vaultUri", "type": "str"}, + "key_vault_cert_name": {"key": "keyVaultCertName", "type": "str"}, + "cert_version": {"key": "certVersion", "type": "str"}, + "exclude_private_key": {"key": "excludePrivateKey", "type": "bool"}, } def __init__( @@ -5307,13 +4969,13 @@ def __init__( vault_uri: str, key_vault_cert_name: str, cert_version: Optional[str] = None, - exclude_private_key: Optional[bool] = False, + exclude_private_key: bool = False, **kwargs ): """ - :keyword vault_uri: Required. The vault uri of user key vault. + :keyword vault_uri: The vault uri of user key vault. Required. :paramtype vault_uri: str - :keyword key_vault_cert_name: Required. The certificate name of key vault. + :keyword key_vault_cert_name: The certificate name of key vault. Required. :paramtype key_vault_cert_name: str :keyword cert_version: The certificate version of key vault. :paramtype cert_version: str @@ -5321,20 +4983,20 @@ def __init__( vault. :paramtype exclude_private_key: bool """ - super(KeyVaultCertificateProperties, self).__init__(**kwargs) - self.type = 'KeyVaultCertificate' # type: str + super().__init__(**kwargs) + self.type = "KeyVaultCertificate" # type: str self.vault_uri = vault_uri self.key_vault_cert_name = key_vault_cert_name self.cert_version = cert_version self.exclude_private_key = exclude_private_key -class LoadedCertificate(msrest.serialization.Model): +class LoadedCertificate(_serialization.Model): """Loaded certificate payload. All required parameters must be populated in order to send to Azure. - :ivar resource_id: Required. Resource Id of loaded certificate. + :ivar resource_id: Resource Id of loaded certificate. Required. :vartype resource_id: str :ivar load_trust_store: Indicate whether the certificate will be loaded into default trust store, only work for Java runtime. @@ -5342,65 +5004,54 @@ class LoadedCertificate(msrest.serialization.Model): """ _validation = { - 'resource_id': {'required': True}, + "resource_id": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'load_trust_store': {'key': 'loadTrustStore', 'type': 'bool'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "load_trust_store": {"key": "loadTrustStore", "type": "bool"}, } - def __init__( - self, - *, - resource_id: str, - load_trust_store: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, resource_id: str, load_trust_store: bool = False, **kwargs): """ - :keyword resource_id: Required. Resource Id of loaded certificate. + :keyword resource_id: Resource Id of loaded certificate. Required. :paramtype resource_id: str :keyword load_trust_store: Indicate whether the certificate will be loaded into default trust store, only work for Java runtime. :paramtype load_trust_store: bool """ - super(LoadedCertificate, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.load_trust_store = load_trust_store -class LogFileUrlResponse(msrest.serialization.Model): +class LogFileUrlResponse(_serialization.Model): """Log file URL payload. All required parameters must be populated in order to send to Azure. - :ivar url: Required. URL of the log file. + :ivar url: URL of the log file. Required. :vartype url: str """ _validation = { - 'url': {'required': True}, + "url": {"required": True}, } _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, } - def __init__( - self, - *, - url: str, - **kwargs - ): + def __init__(self, *, url: str, **kwargs): """ - :keyword url: Required. URL of the log file. + :keyword url: URL of the log file. Required. :paramtype url: str """ - super(LogFileUrlResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url -class LogSpecification(msrest.serialization.Model): +class LogSpecification(_serialization.Model): """Specifications of the Log for Azure Monitoring. :ivar name: Name of the log. @@ -5412,9 +5063,9 @@ class LogSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, } def __init__( @@ -5433,17 +5084,17 @@ def __init__( :keyword blob_duration: Blob duration of the log. :paramtype blob_duration: str """ - super(LogSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class ManagedIdentityProperties(msrest.serialization.Model): +class ManagedIdentityProperties(_serialization.Model): """Managed identity properties retrieved from ARM request headers. - :ivar type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ManagedIdentityType :ivar principal_id: Principal Id of system-assigned managed identity. :vartype principal_id: str @@ -5455,24 +5106,24 @@ class ManagedIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedManagedIdentity}'}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedManagedIdentity}"}, } def __init__( self, *, - type: Optional[Union[str, "ManagedIdentityType"]] = None, + type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedManagedIdentity"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedManagedIdentity"]] = None, **kwargs ): """ - :keyword type: Type of the managed identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ManagedIdentityType :keyword principal_id: Principal Id of system-assigned managed identity. :paramtype principal_id: str @@ -5482,14 +5133,14 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.appplatform.v2022_05_01_preview.models.UserAssignedManagedIdentity] """ - super(ManagedIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.principal_id = principal_id self.tenant_id = tenant_id self.user_assigned_identities = user_assigned_identities -class MarketplaceResource(msrest.serialization.Model): +class MarketplaceResource(_serialization.Model): """Purchasing 3rd Party product for one Azure Spring Apps instance. :ivar plan: The plan id of the 3rd Party Artifact that is being procured. @@ -5501,18 +5152,13 @@ class MarketplaceResource(msrest.serialization.Model): """ _attribute_map = { - 'plan': {'key': 'plan', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, + "plan": {"key": "plan", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, } def __init__( - self, - *, - plan: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - **kwargs + self, *, plan: Optional[str] = None, publisher: Optional[str] = None, product: Optional[str] = None, **kwargs ): """ :keyword plan: The plan id of the 3rd Party Artifact that is being procured. @@ -5522,13 +5168,13 @@ def __init__( :keyword product: The 3rd Party artifact that is being procured. :paramtype product: str """ - super(MarketplaceResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.plan = plan self.publisher = publisher self.product = product -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """Specifications of the Dimension of metrics. :ivar name: Name of the dimension. @@ -5541,9 +5187,9 @@ class MetricDimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -5563,13 +5209,13 @@ def __init__( export scenario. :paramtype to_be_exported_for_shoebox: bool """ - super(MetricDimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes """Specifications of the Metrics for Azure Monitoring. :ivar name: Name of the metric. @@ -5600,17 +5246,17 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "source_mdm_namespace": {"key": "sourceMdmNamespace", "type": "str"}, } def __init__( @@ -5625,7 +5271,7 @@ def __init__( supported_aggregation_types: Optional[List[str]] = None, supported_time_grain_types: Optional[List[str]] = None, fill_gap_with_zero: Optional[bool] = None, - dimensions: Optional[List["MetricDimension"]] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, source_mdm_namespace: Optional[str] = None, **kwargs ): @@ -5656,7 +5302,7 @@ def __init__( :keyword source_mdm_namespace: Name of the MDM namespace. Optional. :paramtype source_mdm_namespace: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -5670,13 +5316,13 @@ def __init__( self.source_mdm_namespace = source_mdm_namespace -class MonitoringSettingProperties(msrest.serialization.Model): +class MonitoringSettingProperties(_serialization.Model): """Monitoring Setting properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Monitoring Setting. Possible values include: - "NotAvailable", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: State of the Monitoring Setting. Known values are: "NotAvailable", + "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingState :ivar error: Error when apply Monitoring Setting changes. @@ -5697,27 +5343,27 @@ class MonitoringSettingProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'app_insights_sampling_rate': {'maximum': 100, 'minimum': 0}, + "provisioning_state": {"readonly": True}, + "app_insights_sampling_rate": {"maximum": 100, "minimum": 0}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'trace_enabled': {'key': 'traceEnabled', 'type': 'bool'}, - 'app_insights_instrumentation_key': {'key': 'appInsightsInstrumentationKey', 'type': 'str'}, - 'app_insights_sampling_rate': {'key': 'appInsightsSamplingRate', 'type': 'float'}, - 'app_insights_agent_versions': {'key': 'appInsightsAgentVersions', 'type': 'ApplicationInsightsAgentVersions'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "trace_enabled": {"key": "traceEnabled", "type": "bool"}, + "app_insights_instrumentation_key": {"key": "appInsightsInstrumentationKey", "type": "str"}, + "app_insights_sampling_rate": {"key": "appInsightsSamplingRate", "type": "float"}, + "app_insights_agent_versions": {"key": "appInsightsAgentVersions", "type": "ApplicationInsightsAgentVersions"}, } def __init__( self, *, - error: Optional["Error"] = None, + error: Optional["_models.Error"] = None, trace_enabled: Optional[bool] = None, app_insights_instrumentation_key: Optional[str] = None, app_insights_sampling_rate: Optional[float] = None, - app_insights_agent_versions: Optional["ApplicationInsightsAgentVersions"] = None, + app_insights_agent_versions: Optional["_models.ApplicationInsightsAgentVersions"] = None, **kwargs ): """ @@ -5737,7 +5383,7 @@ def __init__( :paramtype app_insights_agent_versions: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApplicationInsightsAgentVersions """ - super(MonitoringSettingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.error = error self.trace_enabled = trace_enabled @@ -5765,36 +5411,31 @@ class MonitoringSettingResource(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': 'MonitoringSettingProperties'}, + "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": "MonitoringSettingProperties"}, } - def __init__( - self, - *, - properties: Optional["MonitoringSettingProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.MonitoringSettingProperties"] = None, **kwargs): """ :keyword properties: Properties of the Monitoring Setting resource. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingProperties """ - super(MonitoringSettingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class NameAvailability(msrest.serialization.Model): +class NameAvailability(_serialization.Model): """Name availability result payload. :ivar name_available: Indicates whether the name is available. @@ -5806,9 +5447,9 @@ class NameAvailability(msrest.serialization.Model): """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } def __init__( @@ -5827,47 +5468,41 @@ def __init__( :keyword message: Message why the name is not available. :paramtype message: str """ - super(NameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class NameAvailabilityParameters(msrest.serialization.Model): +class NameAvailabilityParameters(_serialization.Model): """Name availability parameters payload. All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the resource to check name availability. + :ivar type: Type of the resource to check name availability. Required. :vartype type: str - :ivar name: Required. Name to be checked. + :ivar name: Name to be checked. Required. :vartype name: str """ _validation = { - 'type': {'required': True}, - 'name': {'required': True}, + "type": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - type: str, - name: str, - **kwargs - ): + def __init__(self, *, type: str, name: str, **kwargs): """ - :keyword type: Required. Type of the resource to check name availability. + :keyword type: Type of the resource to check name availability. Required. :paramtype type: str - :keyword name: Required. Name to be checked. + :keyword name: Name to be checked. Required. :paramtype name: str """ - super(NameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name @@ -5877,7 +5512,7 @@ class NetCoreZipUploadedUserSourceInfo(UploadedUserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -5890,15 +5525,15 @@ class NetCoreZipUploadedUserSourceInfo(UploadedUserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'net_core_main_entry_path': {'key': 'netCoreMainEntryPath', 'type': 'str'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "net_core_main_entry_path": {"key": "netCoreMainEntryPath", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, } def __init__( @@ -5920,13 +5555,13 @@ def __init__( :keyword runtime_version: Runtime version of the .Net file. :paramtype runtime_version: str """ - super(NetCoreZipUploadedUserSourceInfo, self).__init__(version=version, relative_path=relative_path, **kwargs) - self.type = 'NetCoreZip' # type: str + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "NetCoreZip" # type: str self.net_core_main_entry_path = net_core_main_entry_path self.runtime_version = runtime_version -class NetworkProfile(msrest.serialization.Model): +class NetworkProfile(_serialization.Model): """Service network profile payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -5956,19 +5591,19 @@ class NetworkProfile(msrest.serialization.Model): """ _validation = { - 'outbound_i_ps': {'readonly': True}, - 'required_traffics': {'readonly': True}, + "outbound_i_ps": {"readonly": True}, + "required_traffics": {"readonly": True}, } _attribute_map = { - 'service_runtime_subnet_id': {'key': 'serviceRuntimeSubnetId', 'type': 'str'}, - 'app_subnet_id': {'key': 'appSubnetId', 'type': 'str'}, - 'service_cidr': {'key': 'serviceCidr', 'type': 'str'}, - 'service_runtime_network_resource_group': {'key': 'serviceRuntimeNetworkResourceGroup', 'type': 'str'}, - 'app_network_resource_group': {'key': 'appNetworkResourceGroup', 'type': 'str'}, - 'outbound_i_ps': {'key': 'outboundIPs', 'type': 'NetworkProfileOutboundIPs'}, - 'required_traffics': {'key': 'requiredTraffics', 'type': '[RequiredTraffic]'}, - 'ingress_config': {'key': 'ingressConfig', 'type': 'IngressConfig'}, + "service_runtime_subnet_id": {"key": "serviceRuntimeSubnetId", "type": "str"}, + "app_subnet_id": {"key": "appSubnetId", "type": "str"}, + "service_cidr": {"key": "serviceCidr", "type": "str"}, + "service_runtime_network_resource_group": {"key": "serviceRuntimeNetworkResourceGroup", "type": "str"}, + "app_network_resource_group": {"key": "appNetworkResourceGroup", "type": "str"}, + "outbound_i_ps": {"key": "outboundIPs", "type": "NetworkProfileOutboundIPs"}, + "required_traffics": {"key": "requiredTraffics", "type": "[RequiredTraffic]"}, + "ingress_config": {"key": "ingressConfig", "type": "IngressConfig"}, } def __init__( @@ -5979,7 +5614,7 @@ def __init__( service_cidr: Optional[str] = None, service_runtime_network_resource_group: Optional[str] = None, app_network_resource_group: Optional[str] = None, - ingress_config: Optional["IngressConfig"] = None, + ingress_config: Optional["_models.IngressConfig"] = None, **kwargs ): """ @@ -6000,7 +5635,7 @@ def __init__( :keyword ingress_config: Ingress configuration payload for Azure Spring Apps resource. :paramtype ingress_config: ~azure.mgmt.appplatform.v2022_05_01_preview.models.IngressConfig """ - super(NetworkProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_runtime_subnet_id = service_runtime_subnet_id self.app_subnet_id = app_subnet_id self.service_cidr = service_cidr @@ -6011,7 +5646,7 @@ def __init__( self.ingress_config = ingress_config -class NetworkProfileOutboundIPs(msrest.serialization.Model): +class NetworkProfileOutboundIPs(_serialization.Model): """Desired outbound IP resources for Azure Spring Apps resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -6021,24 +5656,20 @@ class NetworkProfileOutboundIPs(msrest.serialization.Model): """ _validation = { - 'public_i_ps': {'readonly': True}, + "public_i_ps": {"readonly": True}, } _attribute_map = { - 'public_i_ps': {'key': 'publicIPs', 'type': '[str]'}, + "public_i_ps": {"key": "publicIPs", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(NetworkProfileOutboundIPs, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.public_i_ps = None -class OperationDetail(msrest.serialization.Model): +class OperationDetail(_serialization.Model): """Operation detail payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -6050,7 +5681,7 @@ class OperationDetail(msrest.serialization.Model): :ivar display: Display of the operation. :vartype display: ~azure.mgmt.appplatform.v2022_05_01_preview.models.OperationDisplay :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. Possible values include: "Internal". + internal only APIs. "Internal" :vartype action_type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ActionType :ivar origin: Origin of the operation. :vartype origin: str @@ -6059,16 +5690,16 @@ class OperationDetail(msrest.serialization.Model): """ _validation = { - 'action_type': {'readonly': True}, + "action_type": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'action_type': {'key': 'actionType', 'type': 'str'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "action_type": {"key": "actionType", "type": "str"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "OperationProperties"}, } def __init__( @@ -6076,9 +5707,9 @@ 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, - properties: Optional["OperationProperties"] = None, + properties: Optional["_models.OperationProperties"] = None, **kwargs ): """ @@ -6093,7 +5724,7 @@ def __init__( :keyword properties: Properties of the operation. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.OperationProperties """ - super(OperationDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display @@ -6102,7 +5733,7 @@ def __init__( self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display payload. :ivar provider: Resource provider of the operation. @@ -6116,10 +5747,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__( @@ -6141,14 +5772,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 OperationProperties(msrest.serialization.Model): +class OperationProperties(_serialization.Model): """Extra Operation properties. :ivar service_specification: Service specifications of the operation. @@ -6157,25 +5788,20 @@ class OperationProperties(msrest.serialization.Model): """ _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, } - def __init__( - self, - *, - service_specification: Optional["ServiceSpecification"] = None, - **kwargs - ): + def __init__(self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs): """ :keyword service_specification: Service specifications of the operation. :paramtype service_specification: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceSpecification """ - super(OperationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_specification = service_specification -class PersistentDisk(msrest.serialization.Model): +class PersistentDisk(_serialization.Model): """Persistent disk payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -6189,43 +5815,37 @@ class PersistentDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 50, 'minimum': 0}, - 'used_in_gb': {'readonly': True, 'maximum': 50, 'minimum': 0}, + "size_in_gb": {"maximum": 50, "minimum": 0}, + "used_in_gb": {"readonly": True, "maximum": 50, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'used_in_gb': {'key': 'usedInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "used_in_gb": {"key": "usedInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: Optional[str] = None, **kwargs): """ :keyword size_in_gb: Size of the persistent disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the persistent disk. :paramtype mount_path: str """ - super(PersistentDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.used_in_gb = None self.mount_path = mount_path -class Probe(msrest.serialization.Model): +class Probe(_serialization.Model): """Probe describes a health check to be performed against an App Instance to determine whether it is alive or ready to receive traffic. All required parameters must be populated in order to send to Azure. :ivar probe_action: The action of the probe. :vartype probe_action: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ProbeAction - :ivar disable_probe: Required. Indicate whether the probe is disabled. + :ivar disable_probe: Indicate whether the probe is disabled. Required. :vartype disable_probe: bool :ivar initial_delay_seconds: Number of seconds after the App Instance has started before probes are initiated. More info: @@ -6244,24 +5864,24 @@ class Probe(msrest.serialization.Model): """ _validation = { - 'disable_probe': {'required': True}, + "disable_probe": {"required": True}, } _attribute_map = { - 'probe_action': {'key': 'probeAction', 'type': 'ProbeAction'}, - 'disable_probe': {'key': 'disableProbe', 'type': 'bool'}, - 'initial_delay_seconds': {'key': 'initialDelaySeconds', 'type': 'int'}, - 'period_seconds': {'key': 'periodSeconds', 'type': 'int'}, - 'timeout_seconds': {'key': 'timeoutSeconds', 'type': 'int'}, - 'failure_threshold': {'key': 'failureThreshold', 'type': 'int'}, - 'success_threshold': {'key': 'successThreshold', 'type': 'int'}, + "probe_action": {"key": "probeAction", "type": "ProbeAction"}, + "disable_probe": {"key": "disableProbe", "type": "bool"}, + "initial_delay_seconds": {"key": "initialDelaySeconds", "type": "int"}, + "period_seconds": {"key": "periodSeconds", "type": "int"}, + "timeout_seconds": {"key": "timeoutSeconds", "type": "int"}, + "failure_threshold": {"key": "failureThreshold", "type": "int"}, + "success_threshold": {"key": "successThreshold", "type": "int"}, } def __init__( self, *, - disable_probe: bool, - probe_action: Optional["ProbeAction"] = None, + disable_probe: bool = False, + probe_action: Optional["_models.ProbeAction"] = None, initial_delay_seconds: Optional[int] = None, period_seconds: Optional[int] = None, timeout_seconds: Optional[int] = None, @@ -6272,7 +5892,7 @@ def __init__( """ :keyword probe_action: The action of the probe. :paramtype probe_action: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ProbeAction - :keyword disable_probe: Required. Indicate whether the probe is disabled. + :keyword disable_probe: Indicate whether the probe is disabled. Required. :paramtype disable_probe: bool :keyword initial_delay_seconds: Number of seconds after the App Instance has started before probes are initiated. More info: @@ -6290,7 +5910,7 @@ def __init__( successful after having failed. Must be 1 for liveness and startup. Minimum value is 1. :paramtype success_threshold: int """ - super(Probe, self).__init__(**kwargs) + super().__init__(**kwargs) self.probe_action = probe_action self.disable_probe = disable_probe self.initial_delay_seconds = initial_delay_seconds @@ -6300,40 +5920,33 @@ def __init__( self.success_threshold = success_threshold -class RegenerateTestKeyRequestPayload(msrest.serialization.Model): +class RegenerateTestKeyRequestPayload(_serialization.Model): """Regenerate test key request payload. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :ivar key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :vartype key_type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.TestKeyType """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "TestKeyType"], - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.TestKeyType"], **kwargs): """ - :keyword key_type: Required. Type of the test key. Possible values include: "Primary", - "Secondary". + :keyword key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". :paramtype key_type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.TestKeyType """ - super(RegenerateTestKeyRequestPayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type -class RequiredTraffic(msrest.serialization.Model): +class RequiredTraffic(_serialization.Model): """Required inbound or outbound traffic for Azure Spring Apps resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -6346,34 +5959,29 @@ class RequiredTraffic(msrest.serialization.Model): :vartype ips: list[str] :ivar fqdns: The FQDN list of required traffic. :vartype fqdns: list[str] - :ivar direction: The direction of required traffic. Possible values include: "Inbound", - "Outbound". + :ivar direction: The direction of required traffic. Known values are: "Inbound" and "Outbound". :vartype direction: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.TrafficDirection """ _validation = { - 'protocol': {'readonly': True}, - 'port': {'readonly': True}, - 'ips': {'readonly': True}, - 'fqdns': {'readonly': True}, - 'direction': {'readonly': True}, + "protocol": {"readonly": True}, + "port": {"readonly": True}, + "ips": {"readonly": True}, + "fqdns": {"readonly": True}, + "direction": {"readonly": True}, } _attribute_map = { - 'protocol': {'key': 'protocol', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - 'ips': {'key': 'ips', 'type': '[str]'}, - 'fqdns': {'key': 'fqdns', 'type': '[str]'}, - 'direction': {'key': 'direction', 'type': 'str'}, + "protocol": {"key": "protocol", "type": "str"}, + "port": {"key": "port", "type": "int"}, + "ips": {"key": "ips", "type": "[str]"}, + "fqdns": {"key": "fqdns", "type": "[str]"}, + "direction": {"key": "direction", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RequiredTraffic, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.protocol = None self.port = None self.ips = None @@ -6381,7 +5989,7 @@ def __init__( self.direction = None -class ResourceRequests(msrest.serialization.Model): +class ResourceRequests(_serialization.Model): """Deployment resource request payload. :ivar cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 for @@ -6393,17 +6001,11 @@ class ResourceRequests(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, } - def __init__( - self, - *, - cpu: Optional[str] = None, - memory: Optional[str] = None, - **kwargs - ): + def __init__(self, *, cpu: Optional[str] = None, memory: Optional[str] = None, **kwargs): """ :keyword cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 for Basic tier, and {500m, 1, 2, 3, 4} for Standard tier. @@ -6412,12 +6014,12 @@ def __init__( {512Mi, 1Gi, 2Gi} for Basic tier, and {512Mi, 1Gi, 2Gi, ..., 8Gi} for Standard tier. :paramtype memory: str """ - super(ResourceRequests, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory = memory -class ResourceSku(msrest.serialization.Model): +class ResourceSku(_serialization.Model): """Describes an available Azure Spring Apps SKU. :ivar resource_type: Gets the type of resource the SKU applies to. @@ -6441,13 +6043,13 @@ class ResourceSku(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'SkuCapacity'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[ResourceSkuLocationInfo]'}, - 'restrictions': {'key': 'restrictions', 'type': '[ResourceSkuRestrictions]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "SkuCapacity"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[ResourceSkuLocationInfo]"}, + "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, } def __init__( @@ -6456,10 +6058,10 @@ def __init__( resource_type: Optional[str] = None, name: Optional[str] = None, tier: Optional[str] = None, - capacity: Optional["SkuCapacity"] = None, + capacity: Optional["_models.SkuCapacity"] = None, locations: Optional[List[str]] = None, - location_info: Optional[List["ResourceSkuLocationInfo"]] = None, - restrictions: Optional[List["ResourceSkuRestrictions"]] = None, + location_info: Optional[List["_models.ResourceSkuLocationInfo"]] = None, + restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None, **kwargs ): """ @@ -6482,7 +6084,7 @@ def __init__( :paramtype restrictions: list[~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceSkuRestrictions] """ - super(ResourceSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.name = name self.tier = tier @@ -6492,7 +6094,7 @@ def __init__( self.restrictions = restrictions -class ResourceSkuCapabilities(msrest.serialization.Model): +class ResourceSkuCapabilities(_serialization.Model): """ResourceSkuCapabilities. :ivar name: Gets an invariant to describe the feature. @@ -6502,29 +6104,23 @@ class ResourceSkuCapabilities(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: Gets an invariant to describe the feature. :paramtype name: str :keyword value: Gets an invariant if the feature is measured by quantity. :paramtype value: str """ - super(ResourceSkuCapabilities, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class ResourceSkuCollection(msrest.serialization.Model): +class ResourceSkuCollection(_serialization.Model): """Object that includes an array of Azure Spring Apps SKU and a possible link for next set. :ivar value: Collection of resource SKU. @@ -6535,16 +6131,12 @@ class ResourceSkuCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ResourceSku"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ResourceSku"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of resource SKU. @@ -6553,12 +6145,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ResourceSkuCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ResourceSkuLocationInfo(msrest.serialization.Model): +class ResourceSkuLocationInfo(_serialization.Model): """Locations and availability zones where the SKU is available. :ivar location: Gets location of the SKU. @@ -6571,9 +6163,9 @@ class ResourceSkuLocationInfo(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'zone_details': {'key': 'zoneDetails', 'type': '[ResourceSkuZoneDetails]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "zone_details": {"key": "zoneDetails", "type": "[ResourceSkuZoneDetails]"}, } def __init__( @@ -6581,7 +6173,7 @@ def __init__( *, location: Optional[str] = None, zones: Optional[List[str]] = None, - zone_details: Optional[List["ResourceSkuZoneDetails"]] = None, + zone_details: Optional[List["_models.ResourceSkuZoneDetails"]] = None, **kwargs ): """ @@ -6593,13 +6185,13 @@ def __init__( :paramtype zone_details: list[~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceSkuZoneDetails] """ - super(ResourceSkuLocationInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones self.zone_details = zone_details -class ResourceSkuRestrictionInfo(msrest.serialization.Model): +class ResourceSkuRestrictionInfo(_serialization.Model): """Information about the restriction where the SKU cannot be used. :ivar locations: Gets locations where the SKU is restricted. @@ -6609,33 +6201,27 @@ class ResourceSkuRestrictionInfo(msrest.serialization.Model): """ _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - locations: Optional[List[str]] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, locations: Optional[List[str]] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword locations: Gets locations where the SKU is restricted. :paramtype locations: list[str] :keyword zones: Gets list of availability zones where the SKU is restricted. :paramtype zones: list[str] """ - super(ResourceSkuRestrictionInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.locations = locations self.zones = zones -class ResourceSkuRestrictions(msrest.serialization.Model): +class ResourceSkuRestrictions(_serialization.Model): """Restrictions where the SKU cannot be used. - :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. Known + values are: "Location" and "Zone". :vartype type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceSkuRestrictionsType :ivar values: Gets the value of restrictions. If the restriction type is set to @@ -6646,31 +6232,30 @@ class ResourceSkuRestrictions(msrest.serialization.Model): :vartype restriction_info: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceSkuRestrictionInfo :ivar reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceSkuRestrictionsReasonCode """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'ResourceSkuRestrictionInfo'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "restriction_info": {"key": "restrictionInfo", "type": "ResourceSkuRestrictionInfo"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceSkuRestrictionsType"]] = None, + type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None, values: Optional[List[str]] = None, - restriction_info: Optional["ResourceSkuRestrictionInfo"] = None, - reason_code: Optional[Union[str, "ResourceSkuRestrictionsReasonCode"]] = None, + restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None, + reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None, **kwargs ): """ :keyword type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. - Possible values include: "Location", "Zone". + Known values are: "Location" and "Zone". :paramtype type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceSkuRestrictionsType :keyword values: Gets the value of restrictions. If the restriction type is set to @@ -6681,19 +6266,18 @@ def __init__( :paramtype restriction_info: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceSkuRestrictionInfo :keyword reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', - 'NotAvailableForSubscription'. Possible values include: "QuotaId", - "NotAvailableForSubscription". + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceSkuRestrictionsReasonCode """ - super(ResourceSkuRestrictions, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.values = values self.restriction_info = restriction_info self.reason_code = reason_code -class ResourceSkuZoneDetails(msrest.serialization.Model): +class ResourceSkuZoneDetails(_serialization.Model): """Details of capabilities available to a SKU in specific zones. :ivar name: Gets the set of zones that the SKU is available in with the @@ -6706,15 +6290,15 @@ class ResourceSkuZoneDetails(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[ResourceSkuCapabilities]'}, + "name": {"key": "name", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, } def __init__( self, *, name: Optional[List[str]] = None, - capabilities: Optional[List["ResourceSkuCapabilities"]] = None, + capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None, **kwargs ): """ @@ -6726,12 +6310,12 @@ def __init__( :paramtype capabilities: list[~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceSkuCapabilities] """ - super(ResourceSkuZoneDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.capabilities = capabilities -class ResourceUploadDefinition(msrest.serialization.Model): +class ResourceUploadDefinition(_serialization.Model): """Resource upload definition payload. :ivar relative_path: Source relative path. @@ -6741,29 +6325,23 @@ class ResourceUploadDefinition(msrest.serialization.Model): """ _attribute_map = { - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'upload_url': {'key': 'uploadUrl', 'type': 'str'}, + "relative_path": {"key": "relativePath", "type": "str"}, + "upload_url": {"key": "uploadUrl", "type": "str"}, } - def __init__( - self, - *, - relative_path: Optional[str] = None, - upload_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, relative_path: Optional[str] = None, upload_url: Optional[str] = None, **kwargs): """ :keyword relative_path: Source relative path. :paramtype relative_path: str :keyword upload_url: Upload URL. :paramtype upload_url: str """ - super(ResourceUploadDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.relative_path = relative_path self.upload_url = upload_url -class ServiceRegistryInstance(msrest.serialization.Model): +class ServiceRegistryInstance(_serialization.Model): """Collection of instances belong to the Service Registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -6775,33 +6353,29 @@ class ServiceRegistryInstance(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServiceRegistryInstance, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.status = None -class ServiceRegistryProperties(msrest.serialization.Model): +class ServiceRegistryProperties(_serialization.Model): """Service Registry properties payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: State of the Service Registry. Possible values include: "Creating", - "Updating", "Succeeded", "Failed", "Deleting". + :ivar provisioning_state: State of the Service Registry. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryProvisioningState :ivar resource_requests: The requested resource quantity for required CPU and Memory. @@ -6813,24 +6387,20 @@ class ServiceRegistryProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'resource_requests': {'readonly': True}, - 'instances': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_requests': {'key': 'resourceRequests', 'type': 'ServiceRegistryResourceRequests'}, - 'instances': {'key': 'instances', 'type': '[ServiceRegistryInstance]'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "ServiceRegistryResourceRequests"}, + "instances": {"key": "instances", "type": "[ServiceRegistryInstance]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServiceRegistryProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.resource_requests = None self.instances = None @@ -6855,36 +6425,31 @@ class ServiceRegistryResource(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': 'ServiceRegistryProperties'}, + "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": "ServiceRegistryProperties"}, } - def __init__( - self, - *, - properties: Optional["ServiceRegistryProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ServiceRegistryProperties"] = None, **kwargs): """ :keyword properties: Service Registry properties payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryProperties """ - super(ServiceRegistryResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ServiceRegistryResourceCollection(msrest.serialization.Model): +class ServiceRegistryResourceCollection(_serialization.Model): """Object that includes an array of Service Registry resources and a possible link for next set. :ivar value: Collection of Service Registry resources. @@ -6896,14 +6461,14 @@ class ServiceRegistryResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceRegistryResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServiceRegistryResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ServiceRegistryResource"]] = None, + value: Optional[List["_models.ServiceRegistryResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -6915,12 +6480,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ServiceRegistryResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServiceRegistryResourceRequests(msrest.serialization.Model): +class ServiceRegistryResourceRequests(_serialization.Model): """Resource request payload of Service Registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -6934,24 +6499,20 @@ class ServiceRegistryResourceRequests(msrest.serialization.Model): """ _validation = { - 'cpu': {'readonly': True}, - 'memory': {'readonly': True}, - 'instance_count': {'readonly': True}, + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'str'}, - 'memory': {'key': 'memory', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServiceRegistryResourceRequests, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cpu = None self.memory = None self.instance_count = None @@ -6972,42 +6533,35 @@ class TrackedResource(Resource): :vartype system_data: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SystemData :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] """ _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -7027,8 +6581,7 @@ class ServiceResource(TrackedResource): :vartype system_data: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SystemData :ivar location: The GEO location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] :ivar properties: Properties of the Service resource. :vartype properties: @@ -7038,21 +6591,21 @@ class ServiceResource(TrackedResource): """ _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ClusterResourceProperties'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "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"}, + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "ClusterResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( @@ -7060,15 +6613,15 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - properties: Optional["ClusterResourceProperties"] = None, - sku: Optional["Sku"] = None, + properties: Optional["_models.ClusterResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ :keyword location: The GEO location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] :keyword properties: Properties of the Service resource. :paramtype properties: @@ -7076,12 +6629,12 @@ def __init__( :keyword sku: Sku of the Service resource. :paramtype sku: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Sku """ - super(ServiceResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.properties = properties self.sku = sku -class ServiceResourceList(msrest.serialization.Model): +class ServiceResourceList(_serialization.Model): """Object that includes an array of Service resources and a possible link for next set. :ivar value: Collection of Service resources. @@ -7092,16 +6645,12 @@ class ServiceResourceList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ServiceResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ServiceResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of Service resources. @@ -7110,12 +6659,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(ServiceResourceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification payload. :ivar log_specifications: Specifications of the Log for Azure Monitoring. @@ -7127,15 +6676,15 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } def __init__( self, *, - log_specifications: Optional[List["LogSpecification"]] = None, - metric_specifications: Optional[List["MetricSpecification"]] = None, + log_specifications: Optional[List["_models.LogSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -7146,12 +6695,12 @@ def __init__( :paramtype metric_specifications: list[~azure.mgmt.appplatform.v2022_05_01_preview.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_specifications = log_specifications self.metric_specifications = metric_specifications -class ServiceVNetAddons(msrest.serialization.Model): +class ServiceVNetAddons(_serialization.Model): """Additional Service settings in vnet injection instance. :ivar log_stream_public_endpoint: Indicates whether the log stream in vnet injection instance @@ -7160,25 +6709,20 @@ class ServiceVNetAddons(msrest.serialization.Model): """ _attribute_map = { - 'log_stream_public_endpoint': {'key': 'logStreamPublicEndpoint', 'type': 'bool'}, + "log_stream_public_endpoint": {"key": "logStreamPublicEndpoint", "type": "bool"}, } - def __init__( - self, - *, - log_stream_public_endpoint: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, log_stream_public_endpoint: bool = False, **kwargs): """ :keyword log_stream_public_endpoint: Indicates whether the log stream in vnet injection instance could be accessed from internet. :paramtype log_stream_public_endpoint: bool """ - super(ServiceVNetAddons, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_stream_public_endpoint = log_stream_public_endpoint -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """Sku of Azure Spring Apps. :ivar name: Name of the Sku. @@ -7190,19 +6734,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Optional[str] = "S0", - tier: Optional[str] = "Standard", - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: str = "S0", tier: str = "Standard", capacity: Optional[int] = None, **kwargs): """ :keyword name: Name of the Sku. :paramtype name: str @@ -7211,37 +6748,37 @@ def __init__( :keyword capacity: Current capacity of the target resource. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SkuCapacity(msrest.serialization.Model): +class SkuCapacity(_serialization.Model): """The SKU capacity. All required parameters must be populated in order to send to Azure. - :ivar minimum: Required. Gets or sets the minimum. + :ivar minimum: Gets or sets the minimum. Required. :vartype minimum: int :ivar maximum: Gets or sets the maximum. :vartype maximum: int :ivar default: Gets or sets the default. :vartype default: int - :ivar scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :ivar scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", and + "Automatic". :vartype scale_type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.SkuScaleType """ _validation = { - 'minimum': {'required': True}, + "minimum": {"required": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } def __init__( @@ -7250,21 +6787,21 @@ def __init__( minimum: int, maximum: Optional[int] = None, default: Optional[int] = None, - scale_type: Optional[Union[str, "SkuScaleType"]] = None, + scale_type: Optional[Union[str, "_models.SkuScaleType"]] = None, **kwargs ): """ - :keyword minimum: Required. Gets or sets the minimum. + :keyword minimum: Gets or sets the minimum. Required. :paramtype minimum: int :keyword maximum: Gets or sets the maximum. :paramtype maximum: int :keyword default: Gets or sets the default. :paramtype default: int - :keyword scale_type: Gets or sets the type of the scale. Possible values include: "None", - "Manual", "Automatic". + :keyword scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", + and "Automatic". :paramtype scale_type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.SkuScaleType """ - super(SkuCapacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.minimum = minimum self.maximum = maximum self.default = default @@ -7276,7 +6813,7 @@ class SourceUploadedUserSourceInfo(UploadedUserSourceInfo): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the source uploaded.Constant filled by server. + :ivar type: Type of the source uploaded. Required. :vartype type: str :ivar version: Version of the source. :vartype version: str @@ -7291,15 +6828,15 @@ class SourceUploadedUserSourceInfo(UploadedUserSourceInfo): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'artifact_selector': {'key': 'artifactSelector', 'type': 'str'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "artifact_selector": {"key": "artifactSelector", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, } def __init__( @@ -7323,13 +6860,13 @@ def __init__( :keyword runtime_version: Runtime version of the source file. :paramtype runtime_version: str """ - super(SourceUploadedUserSourceInfo, self).__init__(version=version, relative_path=relative_path, **kwargs) - self.type = 'Source' # type: str + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "Source" # type: str self.artifact_selector = artifact_selector self.runtime_version = runtime_version -class SsoProperties(msrest.serialization.Model): +class SsoProperties(_serialization.Model): """Single sign-on related configuration. :ivar scope: It defines the specific actions applications can be allowed to do on a user's @@ -7344,10 +6881,10 @@ class SsoProperties(msrest.serialization.Model): """ _attribute_map = { - 'scope': {'key': 'scope', 'type': '[str]'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'client_secret': {'key': 'clientSecret', 'type': 'str'}, - 'issuer_uri': {'key': 'issuerUri', 'type': 'str'}, + "scope": {"key": "scope", "type": "[str]"}, + "client_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, + "issuer_uri": {"key": "issuerUri", "type": "str"}, } def __init__( @@ -7370,14 +6907,14 @@ def __init__( :keyword issuer_uri: The URI of Issuer Identifier. :paramtype issuer_uri: str """ - super(SsoProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.scope = scope self.client_id = client_id self.client_secret = client_secret self.issuer_uri = issuer_uri -class StackProperties(msrest.serialization.Model): +class StackProperties(_serialization.Model): """KPack ClusterStack properties payload. :ivar id: Id of the ClusterStack. @@ -7387,16 +6924,12 @@ class StackProperties(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( - self, - *, - id: Optional[str] = None, - version: Optional[str] = None, - **kwargs + self, *, id: Optional[str] = None, version: Optional[str] = None, **kwargs # pylint: disable=redefined-builtin ): """ :keyword id: Id of the ClusterStack. @@ -7404,43 +6937,36 @@ def __init__( :keyword version: Version of the ClusterStack. :paramtype version: str """ - super(StackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.version = version -class StorageProperties(msrest.serialization.Model): +class StorageProperties(_serialization.Model): """Storage resource payload. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: StorageAccount. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + StorageAccount All required parameters must be populated in order to send to Azure. - :ivar storage_type: Required. The type of the storage.Constant filled by server. Possible - values include: "StorageAccount". + :ivar storage_type: The type of the storage. Required. "StorageAccount" :vartype storage_type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageType """ _validation = { - 'storage_type': {'required': True}, + "storage_type": {"required": True}, } _attribute_map = { - 'storage_type': {'key': 'storageType', 'type': 'str'}, + "storage_type": {"key": "storageType", "type": "str"}, } - _subtype_map = { - 'storage_type': {'StorageAccount': 'StorageAccount'} - } + _subtype_map = {"storage_type": {"StorageAccount": "StorageAccount"}} - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.storage_type = None # type: Optional[str] @@ -7449,42 +6975,35 @@ class StorageAccount(StorageProperties): All required parameters must be populated in order to send to Azure. - :ivar storage_type: Required. The type of the storage.Constant filled by server. Possible - values include: "StorageAccount". + :ivar storage_type: The type of the storage. Required. "StorageAccount" :vartype storage_type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageType - :ivar account_name: Required. The account name of the Azure Storage Account. + :ivar account_name: The account name of the Azure Storage Account. Required. :vartype account_name: str - :ivar account_key: Required. The account key of the Azure Storage Account. + :ivar account_key: The account key of the Azure Storage Account. Required. :vartype account_key: str """ _validation = { - 'storage_type': {'required': True}, - 'account_name': {'required': True}, - 'account_key': {'required': True}, + "storage_type": {"required": True}, + "account_name": {"required": True}, + "account_key": {"required": True}, } _attribute_map = { - 'storage_type': {'key': 'storageType', 'type': 'str'}, - 'account_name': {'key': 'accountName', 'type': 'str'}, - 'account_key': {'key': 'accountKey', 'type': 'str'}, + "storage_type": {"key": "storageType", "type": "str"}, + "account_name": {"key": "accountName", "type": "str"}, + "account_key": {"key": "accountKey", "type": "str"}, } - def __init__( - self, - *, - account_name: str, - account_key: str, - **kwargs - ): + def __init__(self, *, account_name: str, account_key: str, **kwargs): """ - :keyword account_name: Required. The account name of the Azure Storage Account. + :keyword account_name: The account name of the Azure Storage Account. Required. :paramtype account_name: str - :keyword account_key: Required. The account key of the Azure Storage Account. + :keyword account_key: The account key of the Azure Storage Account. Required. :paramtype account_key: str """ - super(StorageAccount, self).__init__(**kwargs) - self.storage_type = 'StorageAccount' # type: str + super().__init__(**kwargs) + self.storage_type = "StorageAccount" # type: str self.account_name = account_name self.account_key = account_key @@ -7507,35 +7026,30 @@ class StorageResource(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': 'StorageProperties'}, + "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": "StorageProperties"}, } - def __init__( - self, - *, - properties: Optional["StorageProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.StorageProperties"] = None, **kwargs): """ :keyword properties: Properties of the storage resource payload. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageProperties """ - super(StorageResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class StorageResourceCollection(msrest.serialization.Model): +class StorageResourceCollection(_serialization.Model): """Collection compose of storage resources list and a possible link for next page. :ivar value: The storage resources list. @@ -7545,16 +7059,12 @@ class StorageResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["StorageResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.StorageResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The storage resources list. @@ -7562,7 +7072,7 @@ def __init__( :keyword next_link: The link to next page of storage list. :paramtype next_link: str """ - super(StorageResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -7586,36 +7096,31 @@ class SupportedBuildpackResource(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': 'SupportedBuildpackResourceProperties'}, + "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": "SupportedBuildpackResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["SupportedBuildpackResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.SupportedBuildpackResourceProperties"] = None, **kwargs): """ :keyword properties: Supported buildpack resource properties. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SupportedBuildpackResourceProperties """ - super(SupportedBuildpackResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class SupportedBuildpackResourceProperties(msrest.serialization.Model): +class SupportedBuildpackResourceProperties(_serialization.Model): """Supported buildpack resource properties. :ivar buildpack_id: The id of supported buildpack. @@ -7623,24 +7128,19 @@ class SupportedBuildpackResourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'buildpack_id': {'key': 'buildpackId', 'type': 'str'}, + "buildpack_id": {"key": "buildpackId", "type": "str"}, } - def __init__( - self, - *, - buildpack_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, buildpack_id: Optional[str] = None, **kwargs): """ :keyword buildpack_id: The id of supported buildpack. :paramtype buildpack_id: str """ - super(SupportedBuildpackResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.buildpack_id = buildpack_id -class SupportedBuildpacksCollection(msrest.serialization.Model): +class SupportedBuildpacksCollection(_serialization.Model): """Object that includes an array of supported buildpacks resources and a possible link for next set. :ivar value: Collection of supported buildpacks resources. @@ -7652,14 +7152,14 @@ class SupportedBuildpacksCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedBuildpackResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SupportedBuildpackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["SupportedBuildpackResource"]] = None, + value: Optional[List["_models.SupportedBuildpackResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -7671,19 +7171,19 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(SupportedBuildpacksCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SupportedRuntimeVersion(msrest.serialization.Model): +class SupportedRuntimeVersion(_serialization.Model): """Supported deployment runtime version descriptor. - :ivar value: The raw value which could be passed to deployment CRUD operations. Possible values - include: "Java_8", "Java_11", "Java_17", "NetCore_31". + :ivar value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", "Java_17", and "NetCore_31". :vartype value: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.SupportedRuntimeValue - :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). Known + values are: "Java" and ".NET Core". :vartype platform: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.SupportedRuntimePlatform :ivar version: The detailed version (major.minor) of the platform. @@ -7691,32 +7191,32 @@ class SupportedRuntimeVersion(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'platform': {'key': 'platform', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "platform": {"key": "platform", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - value: Optional[Union[str, "SupportedRuntimeValue"]] = None, - platform: Optional[Union[str, "SupportedRuntimePlatform"]] = None, + value: Optional[Union[str, "_models.SupportedRuntimeValue"]] = None, + platform: Optional[Union[str, "_models.SupportedRuntimePlatform"]] = None, version: Optional[str] = None, **kwargs ): """ - :keyword value: The raw value which could be passed to deployment CRUD operations. Possible - values include: "Java_8", "Java_11", "Java_17", "NetCore_31". + :keyword value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", "Java_17", and "NetCore_31". :paramtype value: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.SupportedRuntimeValue :keyword platform: The platform of this runtime version (possible values: "Java" or ".NET"). - Possible values include: "Java", ".NET Core". + Known values are: "Java" and ".NET Core". :paramtype platform: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.SupportedRuntimePlatform :keyword version: The detailed version (major.minor) of the platform. :paramtype version: str """ - super(SupportedRuntimeVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.platform = platform self.version = version @@ -7741,36 +7241,31 @@ class SupportedStackResource(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': 'SupportedStackResourceProperties'}, + "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": "SupportedStackResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["SupportedStackResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.SupportedStackResourceProperties"] = None, **kwargs): """ :keyword properties: Supported stack resource properties. :paramtype properties: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SupportedStackResourceProperties """ - super(SupportedStackResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class SupportedStackResourceProperties(msrest.serialization.Model): +class SupportedStackResourceProperties(_serialization.Model): """Supported stack resource properties. :ivar stack_id: The id of supported stack. @@ -7780,29 +7275,23 @@ class SupportedStackResourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'stack_id': {'key': 'stackId', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "stack_id": {"key": "stackId", "type": "str"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - *, - stack_id: Optional[str] = None, - version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, stack_id: Optional[str] = None, version: Optional[str] = None, **kwargs): """ :keyword stack_id: The id of supported stack. :paramtype stack_id: str :keyword version: The version of supported stack. :paramtype version: str """ - super(SupportedStackResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.stack_id = stack_id self.version = version -class SupportedStacksCollection(msrest.serialization.Model): +class SupportedStacksCollection(_serialization.Model): """Object that includes an array of supported stacks resources and a possible link for next set. :ivar value: Collection of supported stacks resources. @@ -7813,14 +7302,14 @@ class SupportedStacksCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportedStackResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SupportedStackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["SupportedStackResource"]] = None, + value: Optional[List["_models.SupportedStackResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -7832,26 +7321,26 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(SupportedStacksCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -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.appplatform.v2022_05_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.LastModifiedByType :ivar last_modified_at: The timestamp of resource modification (UTC). @@ -7859,44 +7348,44 @@ class SystemData(msrest.serialization.Model): """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "LastModifiedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.LastModifiedByType :keyword last_modified_at: The timestamp of resource modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -7910,30 +7399,26 @@ class TCPSocketAction(ProbeAction): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the action to take to perform the health check.Constant - filled by server. Possible values include: "HTTPGetAction", "TCPSocketAction", "ExecAction". + :ivar type: The type of the action to take to perform the health check. Required. Known values + are: "HTTPGetAction", "TCPSocketAction", and "ExecAction". :vartype type: str or ~azure.mgmt.appplatform.v2022_05_01_preview.models.ProbeActionType """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TCPSocketAction, self).__init__(**kwargs) - self.type = 'TCPSocketAction' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type = "TCPSocketAction" # type: str -class TemporaryDisk(msrest.serialization.Model): +class TemporaryDisk(_serialization.Model): """Temporary disk payload. :ivar size_in_gb: Size of the temporary disk in GB. @@ -7943,33 +7428,27 @@ class TemporaryDisk(msrest.serialization.Model): """ _validation = { - 'size_in_gb': {'maximum': 5, 'minimum': 0}, + "size_in_gb": {"maximum": 5, "minimum": 0}, } _attribute_map = { - 'size_in_gb': {'key': 'sizeInGB', 'type': 'int'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - size_in_gb: Optional[int] = None, - mount_path: Optional[str] = "/tmp", - **kwargs - ): + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: str = "/tmp", **kwargs): """ :keyword size_in_gb: Size of the temporary disk in GB. :paramtype size_in_gb: int :keyword mount_path: Mount path of the temporary disk. :paramtype mount_path: str """ - super(TemporaryDisk, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_gb = size_in_gb self.mount_path = mount_path -class TestKeys(msrest.serialization.Model): +class TestKeys(_serialization.Model): """Test keys payload. :ivar primary_key: Primary key. @@ -7985,11 +7464,11 @@ class TestKeys(msrest.serialization.Model): """ _attribute_map = { - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'primary_test_endpoint': {'key': 'primaryTestEndpoint', 'type': 'str'}, - 'secondary_test_endpoint': {'key': 'secondaryTestEndpoint', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "primary_test_endpoint": {"key": "primaryTestEndpoint", "type": "str"}, + "secondary_test_endpoint": {"key": "secondaryTestEndpoint", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, } def __init__( @@ -8014,7 +7493,7 @@ def __init__( :keyword enabled: Indicates whether the test endpoint feature enabled or not. :paramtype enabled: bool """ - super(TestKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_key = primary_key self.secondary_key = secondary_key self.primary_test_endpoint = primary_test_endpoint @@ -8022,7 +7501,7 @@ def __init__( self.enabled = enabled -class TriggeredBuildResult(msrest.serialization.Model): +class TriggeredBuildResult(_serialization.Model): """The build result triggered by a build. :ivar id: The unique build id of this build result. @@ -8030,24 +7509,19 @@ class TriggeredBuildResult(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The unique build id of this build result. :paramtype id: str """ - super(TriggeredBuildResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class UserAssignedManagedIdentity(msrest.serialization.Model): +class UserAssignedManagedIdentity(_serialization.Model): """The details of the user-assigned managed identity assigned to an App. Variables are only populated by the server, and will be ignored when sending a request. @@ -8059,27 +7533,23 @@ class UserAssignedManagedIdentity(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(UserAssignedManagedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class ValidationMessages(msrest.serialization.Model): +class ValidationMessages(_serialization.Model): """Validate messages of the configuration service git repositories. :ivar name: The name of the configuration service git repository. @@ -8089,23 +7559,17 @@ class ValidationMessages(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'messages': {'key': 'messages', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - messages: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs): """ :keyword name: The name of the configuration service git repository. :paramtype name: str :keyword messages: Detailed validation messages. :paramtype messages: list[str] """ - super(ValidationMessages, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.messages = messages diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/__init__.py index 0da100b4246c..57694a8d82f6 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/__init__.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/__init__.py @@ -30,28 +30,34 @@ from ._api_portals_operations import ApiPortalsOperations from ._api_portal_custom_domains_operations import ApiPortalCustomDomainsOperations +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__ = [ - 'ServicesOperations', - 'ConfigServersOperations', - 'ConfigurationServicesOperations', - 'ServiceRegistriesOperations', - 'BuildServiceOperations', - 'BuildpackBindingOperations', - 'BuildServiceBuilderOperations', - 'BuildServiceAgentPoolOperations', - 'MonitoringSettingsOperations', - 'AppsOperations', - 'BindingsOperations', - 'StoragesOperations', - 'CertificatesOperations', - 'CustomDomainsOperations', - 'DeploymentsOperations', - 'Operations', - 'RuntimeVersionsOperations', - 'SkusOperations', - 'GatewaysOperations', - 'GatewayRouteConfigsOperations', - 'GatewayCustomDomainsOperations', - 'ApiPortalsOperations', - 'ApiPortalCustomDomainsOperations', + "ServicesOperations", + "ConfigServersOperations", + "ConfigurationServicesOperations", + "ServiceRegistriesOperations", + "BuildServiceOperations", + "BuildpackBindingOperations", + "BuildServiceBuilderOperations", + "BuildServiceAgentPoolOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "StoragesOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", + "GatewaysOperations", + "GatewayRouteConfigsOperations", + "GatewayCustomDomainsOperations", + "ApiPortalsOperations", + "ApiPortalCustomDomainsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_api_portal_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_api_portal_custom_domains_operations.py index e422fc49e55d..3cd7b539a686 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_api_portal_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_api_portal_custom_domains_operations.py @@ -6,282 +6,287 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, +def build_delete_request( resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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 ApiPortalCustomDomainsOperations(object): - """ApiPortalCustomDomainsOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApiPortalCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`api_portal_custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.ApiPortalCustomDomainResource": + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any + ) -> _models.ApiPortalCustomDomainResource: """Get the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiPortalCustomDomainResource, or the result of cls(response) + :return: ApiPortalCustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore def _create_or_update_initial( self, @@ -289,39 +294,55 @@ def _create_or_update_initial( service_name: str, api_portal_name: str, domain_name: str, - api_portal_custom_domain_resource: "_models.ApiPortalCustomDomainResource", + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], **kwargs: Any - ) -> "_models.ApiPortalCustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] + ) -> _models.ApiPortalCustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(api_portal_custom_domain_resource, 'ApiPortalCustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_custom_domain_resource, (IO, bytes)): + _content = api_portal_custom_domain_resource + else: + _json = self._serialize.body(api_portal_custom_domain_resource, "ApiPortalCustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: @@ -329,18 +350,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: _models.ApiPortalCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -349,24 +458,27 @@ def begin_create_or_update( service_name: str, api_portal_name: str, domain_name: str, - api_portal_custom_domain_resource: "_models.ApiPortalCustomDomainResource", + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.ApiPortalCustomDomainResource"]: + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: """Create or update the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_name: str :param api_portal_custom_domain_resource: The API portal custom domain for the create or update - operation. + operation. Is either a model type or a IO type. Required. :type api_portal_custom_domain_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -379,19 +491,21 @@ def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + 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, service_name=service_name, api_portal_name=api_portal_name, @@ -399,67 +513,73 @@ def begin_create_or_update( api_portal_custom_domain_resource=api_portal_custom_domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiPortalCustomDomainResource', pipeline_response) + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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]: @@ -469,28 +589,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - domain_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the API portal custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param domain_name: The name of the API portal custom domain. + :param domain_name: The name of the API portal custom domain. Required. :type domain_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. @@ -502,104 +616,120 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, api_portal_name=api_portal_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any - ) -> Iterable["_models.ApiPortalCustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> Iterable["_models.ApiPortalCustomDomainResource"]: """Handle requests to list all API portal custom domains. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiPortalCustomDomainResourceCollection or the - result of cls(response) + :return: An iterator like instance of either ApiPortalCustomDomainResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalCustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, api_portal_name=api_portal_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, - service_name=service_name, - api_portal_name=api_portal_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -613,10 +743,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 @@ -626,8 +754,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_api_portals_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_api_portals_operations.py index 4f4d9e417d1b..372812ac242a 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_api_portals_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_api_portals_operations.py @@ -6,354 +6,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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, - service_name: str, - api_portal_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, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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, - service_name: str, - api_portal_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, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_domain_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - api_portal_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, api_portal_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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 ApiPortalsOperations(object): - """ApiPortalsOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 ApiPortalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`api_portals` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any - ) -> "_models.ApiPortalResource": + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> _models.ApiPortalResource: """Get the API portal and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiPortalResource, or the result of cls(response) + :return: ApiPortalResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, api_portal_name: str, - api_portal_resource: "_models.ApiPortalResource", + api_portal_resource: Union[_models.ApiPortalResource, IO], **kwargs: Any - ) -> "_models.ApiPortalResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] + ) -> _models.ApiPortalResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(api_portal_resource, 'ApiPortalResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_resource, (IO, bytes)): + _content = api_portal_resource + else: + _json = self._serialize.body(api_portal_resource, "ApiPortalResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: @@ -361,18 +361,97 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: _models.ApiPortalResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -380,20 +459,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, api_portal_name: str, - api_portal_resource: "_models.ApiPortalResource", + api_portal_resource: Union[_models.ApiPortalResource, IO], **kwargs: Any - ) -> LROPoller["_models.ApiPortalResource"]: + ) -> LROPoller[_models.ApiPortalResource]: """Create the default API portal or update the existing API portal. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param api_portal_resource: The API portal for the create or update operation. + :param api_portal_resource: The API portal for the create or update operation. Is either a + model type or a IO type. Required. :type api_portal_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -406,84 +490,93 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + 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, service_name=service_name, api_portal_name=api_portal_name, api_portal_resource=api_portal_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiPortalResource', pipeline_response) + deserialized = self._deserialize("ApiPortalResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, api_portal_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_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]: @@ -493,25 +586,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - api_portal_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the default API portal. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_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. @@ -523,98 +611,113 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, api_portal_name=api_portal_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.ApiPortalResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.ApiPortalResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiPortalResourceCollection or the result of - cls(response) + :return: An iterator like instance of either ApiPortalResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiPortalResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -628,10 +731,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 @@ -641,79 +742,159 @@ 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.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore - @distributed_trace + @overload def validate_domain( self, resource_group_name: str, service_name: str, api_portal_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the domains are valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param api_portal_name: The name of API portal. + :param api_portal_name: The name of API portal. Required. :type api_portal_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, api_portal_name=api_portal_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_apps_operations.py index bb28b7254a98..17dcd692f49a 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_apps_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_apps_operations.py @@ -6,387 +6,350 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, sync_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 sync_status is not None: - _query_parameters['syncStatus'] = _SERIALIZER.query("sync_status", sync_status, 'str') + _params["syncStatus"] = _SERIALIZER.query("sync_status", sync_status, "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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str +def build_list_request(resource_group_name: str, service_name: str, 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_resource_upload_url_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_set_active_deployments_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_set_active_deployments_request( + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_validate_domain_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class AppsOperations(object): - """AppsOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`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 get( @@ -396,102 +359,125 @@ def get( app_name: str, sync_status: Optional[str] = None, **kwargs: Any - ) -> "_models.AppResource": + ) -> _models.AppResource: """Get an App and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param sync_status: Indicates whether sync status. Default value is None. :type sync_status: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppResource, or the result of cls(response) + :return: AppResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, sync_status=sync_status, - template_url=self.get.metadata['url'], + 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) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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, 202]: @@ -499,21 +485,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -521,20 +586,24 @@ def begin_create_or_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Create a new App or update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the create or update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -547,84 +616,93 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, 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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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]: @@ -634,25 +712,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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. @@ -664,83 +737,105 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, app_name=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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore def _update_initial( self, resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(app_resource, 'AppResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=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 [200, 202]: @@ -748,18 +843,97 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -767,20 +941,24 @@ def begin_update( resource_group_name: str, service_name: str, app_name: str, - app_resource: "_models.AppResource", + app_resource: Union[_models.AppResource, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Operation to update an exiting App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param app_resource: Parameters for the update operation. - :type app_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -793,104 +971,118 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, service_name=service_name, app_name=app_name, app_resource=app_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.AppResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.AppResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AppResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AppResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -904,10 +1096,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 @@ -917,112 +1107,129 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore @distributed_trace def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for an App, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore def _set_active_deployments_initial( self, resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> "_models.AppResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] + ) -> _models.AppResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(active_deployment_collection, 'ActiveDeploymentCollection') - - request = build_set_active_deployments_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(active_deployment_collection, (IO, bytes)): + _content = active_deployment_collection + else: + _json = self._serialize.body(active_deployment_collection, "ActiveDeploymentCollection") + + request = build_set_active_deployments_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._set_active_deployments_initial.metadata['url'], + content=_content, + template_url=self._set_active_deployments_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]: @@ -1030,18 +1237,98 @@ def _set_active_deployments_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _set_active_deployments_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + _set_active_deployments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + @overload + def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: _models.ActiveDeploymentCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ActiveDeploymentCollection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_set_active_deployments( @@ -1049,21 +1336,25 @@ def begin_set_active_deployments( resource_group_name: str, service_name: str, app_name: str, - active_deployment_collection: "_models.ActiveDeploymentCollection", + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], **kwargs: Any - ) -> LROPoller["_models.AppResource"]: + ) -> LROPoller[_models.AppResource]: """Set existing Deployment under the app as active. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param active_deployment_collection: A list of Deployment name to be active. + :param active_deployment_collection: A list of Deployment name to be active. Is either a model + type or a IO type. Required. :type active_deployment_collection: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.ActiveDeploymentCollection + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ActiveDeploymentCollection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1076,119 +1367,206 @@ def begin_set_active_deployments( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.AppResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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._set_active_deployments_initial( + raw_result = self._set_active_deployments_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, active_deployment_collection=active_deployment_collection, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AppResource', pipeline_response) + deserialized = self._deserialize("AppResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_set_active_deployments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + begin_set_active_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore - @distributed_trace + @overload def validate_domain( self, resource_group_name: str, service_name: str, app_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the resource name is valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_bindings_operations.py index cec117d6b311..d53bfcdc602d 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_bindings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_bindings_operations.py @@ -6,330 +6,310 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, - service_name: str, - app_name: str, - binding_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, service_name: str, app_name: str, binding_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "bindingName": _SERIALIZER.url("binding_name", binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class BindingsOperations(object): - """BindingsOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`bindings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any - ) -> "_models.BindingResource": + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: """Get a Binding and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BindingResource, or the result of cls(response) + :return: BindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +317,55 @@ def _create_or_update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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, 202]: @@ -377,21 +373,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +481,27 @@ def begin_create_or_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Create a new Binding or update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the create or update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +514,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +536,73 @@ def begin_create_or_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, binding_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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]: @@ -518,28 +612,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - binding_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_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. @@ -551,46 +639,52 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, app_name=app_name, binding_name=binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore def _update_initial( self, @@ -598,39 +692,55 @@ def _update_initial( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> "_models.BindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] + ) -> _models.BindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(binding_resource, 'BindingResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, binding_name=binding_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 [200, 202]: @@ -638,18 +748,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +853,27 @@ def begin_update( service_name: str, app_name: str, binding_name: str, - binding_resource: "_models.BindingResource", + binding_resource: Union[_models.BindingResource, IO], **kwargs: Any - ) -> LROPoller["_models.BindingResource"]: + ) -> LROPoller[_models.BindingResource]: """Operation to update an exiting Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param binding_name: The name of the Binding resource. + :param binding_name: The name of the Binding resource. Required. :type binding_name: str - :param binding_resource: Parameters for the update operation. - :type binding_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +886,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +908,102 @@ def begin_update( binding_resource=binding_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BindingResource', pipeline_response) + deserialized = self._deserialize("BindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.BindingResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.BindingResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 BindingResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BindingResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +1017,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 @@ -816,8 +1028,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_build_service_agent_pool_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_build_service_agent_pool_operations.py index b092ac91e9fb..048dced6f12e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_build_service_agent_pool_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_build_service_agent_pool_operations.py @@ -6,233 +6,246 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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, service_name: str, build_service_name: str, agent_pool_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_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_update_put_request_initial( - subscription_id: str, +def build_update_put_request( resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_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 - ) - -class BuildServiceAgentPoolOperations(object): - """BuildServiceAgentPoolOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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) + + +class BuildServiceAgentPoolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`build_service_agent_pool` 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, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildServiceAgentPoolResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.BuildServiceAgentPoolResource"]: """List build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceAgentPoolResourceCollection or the - result of cls(response) + :return: An iterator like instance of either BuildServiceAgentPoolResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -246,10 +259,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 @@ -259,78 +270,78 @@ 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - agent_pool_name: str, - **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": + self, resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: """Get build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildServiceAgentPoolResource, or the result of cls(response) + :return: BuildServiceAgentPoolResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore def _update_put_initial( self, @@ -338,39 +349,55 @@ def _update_put_initial( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> "_models.BuildServiceAgentPoolResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] + ) -> _models.BuildServiceAgentPoolResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(agent_pool_resource, 'BuildServiceAgentPoolResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(agent_pool_resource, (IO, bytes)): + _content = agent_pool_resource + else: + _json = self._serialize.body(agent_pool_resource, "BuildServiceAgentPoolResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -378,18 +405,104 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: _models.BuildServiceAgentPoolResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( @@ -398,23 +511,27 @@ def begin_update_put( service_name: str, build_service_name: str, agent_pool_name: str, - agent_pool_resource: "_models.BuildServiceAgentPoolResource", + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], **kwargs: Any - ) -> LROPoller["_models.BuildServiceAgentPoolResource"]: + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: """Create or update build service agent pool. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param agent_pool_name: The name of the build service agent pool resource. + :param agent_pool_name: The name of the build service agent pool resource. Required. :type agent_pool_name: str - :param agent_pool_resource: Parameters for the update operation. + :param agent_pool_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type agent_pool_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -427,19 +544,21 @@ def begin_update_put( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceAgentPoolResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceAgentPoolResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, @@ -447,29 +566,32 @@ def begin_update_put( agent_pool_resource=agent_pool_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildServiceAgentPoolResource', pipeline_response) + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_build_service_builder_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_build_service_builder_operations.py index a4a7c4b49830..7e9eed8f2767 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_build_service_builder_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_build_service_builder_operations.py @@ -6,282 +6,287 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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, +def build_delete_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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 BuildServiceBuilderOperations(object): - """BuildServiceBuilderOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BuildServiceBuilderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`build_service_builder` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> "_models.BuilderResource": + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.BuilderResource: """Get a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuilderResource, or the result of cls(response) + :return: BuilderResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore def _create_or_update_initial( self, @@ -289,39 +294,55 @@ def _create_or_update_initial( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> "_models.BuilderResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] + ) -> _models.BuilderResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(builder_resource, 'BuilderResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(builder_resource, (IO, bytes)): + _content = builder_resource + else: + _json = self._serialize.body(builder_resource, "BuilderResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -329,18 +350,103 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: _models.BuilderResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -349,22 +455,27 @@ def begin_create_or_update( service_name: str, build_service_name: str, builder_name: str, - builder_resource: "_models.BuilderResource", + builder_resource: Union[_models.BuilderResource, IO], **kwargs: Any - ) -> LROPoller["_models.BuilderResource"]: + ) -> LROPoller[_models.BuilderResource]: """Create or update a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param builder_resource: The target builder for the create or update operation. - :type builder_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource + :param builder_resource: The target builder for the create or update operation. Is either a + model type or a IO type. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -377,19 +488,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -397,67 +510,73 @@ def begin_create_or_update( builder_resource=builder_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuilderResource', pipeline_response) + deserialized = self._deserialize("BuilderResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, build_service_name: str, builder_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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]: @@ -467,28 +586,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a KPack builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_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. @@ -500,104 +613,119 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuilderResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.BuilderResource"]: """List KPack builders result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuilderResourceCollection or the result of - cls(response) + :return: An iterator like instance of either BuilderResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuilderResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_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, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -611,10 +739,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 @@ -624,8 +750,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_build_service_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_build_service_operations.py index 733d0685f2ca..8acae79447d4 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_build_service_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_build_service_operations.py @@ -6,618 +6,613 @@ # Code generated 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 +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_build_services_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_build_service_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_builds_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_build_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_build_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_list_build_results_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_build_result_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, build_result_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), - "buildResultName": _SERIALIZER.url("build_result_name", build_result_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_name, "str"), + "buildResultName": _SERIALIZER.url("build_result_name", build_result_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_build_result_log_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, build_result_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildName": _SERIALIZER.url("build_name", build_name, 'str'), - "buildResultName": _SERIALIZER.url("build_result_name", build_result_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_name, "str"), + "buildResultName": _SERIALIZER.url("build_result_name", build_result_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_get_resource_upload_url_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_list_supported_buildpacks_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_supported_buildpack_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "buildpackName": _SERIALIZER.url("buildpack_name", buildpack_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildpackName": _SERIALIZER.url("buildpack_name", buildpack_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_supported_stacks_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, build_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_supported_stack_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "stackName": _SERIALIZER.url("stack_name", stack_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "stackName": _SERIALIZER.url("stack_name", stack_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 BuildServiceOperations(object): - """BuildServiceOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BuildServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`build_service` 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_build_services( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildServiceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.BuildService"]: """List build services resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildServiceCollection or the result of - cls(response) + :return: An iterator like instance of either BuildService or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildServiceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildService] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildServiceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_services_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_services.metadata['url'], + template_url=self.list_build_services.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_build_services_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -631,10 +626,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 @@ -644,131 +637,141 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_build_services.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore + list_build_services.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore @distributed_trace def get_build_service( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.BuildService": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.BuildService: """Get a build service resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildService, or the result of cls(response) + :return: BuildService or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildService - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildService"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildService] - request = build_get_build_service_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_service.metadata['url'], + template_url=self.get_build_service.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildService', pipeline_response) + deserialized = self._deserialize("BuildService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore - + get_build_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore @distributed_trace def list_builds( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.Build"]: """List KPack builds. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildCollection or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Build or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_builds_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_builds.metadata['url'], + template_url=self.list_builds.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_builds_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -782,10 +785,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 @@ -795,78 +796,146 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_builds.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore + list_builds.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore @distributed_trace def get_build( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> "_models.Build": + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> _models.Build: """Get a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - request = build_get_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build.metadata['url'], + template_url=self.get_build.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + get_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + + @overload + def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: _models.Build, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Build + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update_build( @@ -875,57 +944,77 @@ def create_or_update_build( service_name: str, build_service_name: str, build_name: str, - build: "_models.Build", + build: Union[_models.Build, IO], **kwargs: Any - ) -> "_models.Build": + ) -> _models.Build: """Create or update a KPack build. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build: Parameters for the create or update operation. - :type build: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Build + :param build: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type build: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Build or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] - _json = self._serialize.body(build, 'Build') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build, (IO, bytes)): + _content = build + else: + _json = self._serialize.body(build, "Build") request = build_create_or_update_build_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_build.metadata['url'], + content=_content, + template_url=self.create_or_update_build.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]: @@ -933,81 +1022,87 @@ def create_or_update_build( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore - + create_or_update_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore @distributed_trace def list_build_results( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - build_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildResultCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> Iterable["_models.BuildResult"]: """List KPack build results. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildResultCollection or the result of - cls(response) + :return: An iterator like instance of either BuildResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildResultCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_results_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_results.metadata['url'], + template_url=self.list_build_results.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_build_results_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - build_service_name=build_service_name, - build_name=build_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1021,10 +1116,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 @@ -1034,11 +1127,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_build_results.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore + list_build_results.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore @distributed_trace def get_build_result( @@ -1049,67 +1140,74 @@ def get_build_result( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResult": + ) -> _models.BuildResult: """Get a KPack build result. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResult, or the result of cls(response) + :return: BuildResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResult] - request = build_get_build_result_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result.metadata['url'], + template_url=self.get_build_result.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResult', pipeline_response) + deserialized = self._deserialize("BuildResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore - + get_build_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore @distributed_trace def get_build_result_log( @@ -1120,387 +1218,407 @@ def get_build_result_log( build_name: str, build_result_name: str, **kwargs: Any - ) -> "_models.BuildResultLog": + ) -> _models.BuildResultLog: """Get a KPack build result log download URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param build_name: The name of the build resource. + :param build_name: The name of the build resource. Required. :type build_name: str - :param build_result_name: The name of the build result resource. + :param build_result_name: The name of the build result resource. Required. :type build_result_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildResultLog, or the result of cls(response) + :return: BuildResultLog or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildResultLog - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildResultLog"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultLog] - request = build_get_build_result_log_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, build_name=build_name, build_result_name=build_result_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_result_log.metadata['url'], + template_url=self.get_build_result_log.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildResultLog', pipeline_response) + deserialized = self._deserialize("BuildResultLog", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_result_log.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore - + get_build_result_log.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore @distributed_trace def get_resource_upload_url( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.ResourceUploadDefinition": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: """Get an resource upload URL for build service, which may be artifacts or source archive. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceUploadDefinition, or the result of cls(response) + :return: ResourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] - request = build_get_resource_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resource_upload_url.metadata['url'], + template_url=self.get_resource_upload_url.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_resource_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore - + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore @distributed_trace def list_supported_buildpacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedBuildpacksCollection: """Get all supported buildpacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpacksCollection, or the result of cls(response) + :return: SupportedBuildpacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SupportedBuildpacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpacksCollection] - request = build_list_supported_buildpacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_buildpacks.metadata['url'], + template_url=self.list_supported_buildpacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedBuildpacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_buildpacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore - + list_supported_buildpacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore @distributed_trace def get_supported_buildpack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - buildpack_name: str, - **kwargs: Any - ) -> "_models.SupportedBuildpackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, **kwargs: Any + ) -> _models.SupportedBuildpackResource: """Get the supported buildpack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param buildpack_name: The name of the buildpack resource. + :param buildpack_name: The name of the buildpack resource. Required. :type buildpack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedBuildpackResource, or the result of cls(response) + :return: SupportedBuildpackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SupportedBuildpackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedBuildpackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpackResource] - request = build_get_supported_buildpack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, buildpack_name=buildpack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_buildpack.metadata['url'], + template_url=self.get_supported_buildpack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedBuildpackResource', pipeline_response) + deserialized = self._deserialize("SupportedBuildpackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_buildpack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore - + get_supported_buildpack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore @distributed_trace def list_supported_stacks( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - **kwargs: Any - ) -> "_models.SupportedStacksCollection": + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedStacksCollection: """Get all supported stacks. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStacksCollection, or the result of cls(response) + :return: SupportedStacksCollection or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SupportedStacksCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStacksCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStacksCollection] - request = build_list_supported_stacks_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_stacks.metadata['url'], + template_url=self.list_supported_stacks.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStacksCollection', pipeline_response) + deserialized = self._deserialize("SupportedStacksCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_supported_stacks.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore - + list_supported_stacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore @distributed_trace def get_supported_stack( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - stack_name: str, - **kwargs: Any - ) -> "_models.SupportedStackResource": + self, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, **kwargs: Any + ) -> _models.SupportedStackResource: """Get the supported stack resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param stack_name: The name of the stack resource. + :param stack_name: The name of the stack resource. Required. :type stack_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SupportedStackResource, or the result of cls(response) + :return: SupportedStackResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.SupportedStackResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedStackResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStackResource] - request = build_get_supported_stack_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, stack_name=stack_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_supported_stack.metadata['url'], + template_url=self.get_supported_stack.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SupportedStackResource', pipeline_response) + deserialized = self._deserialize("SupportedStackResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_supported_stack.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore - + get_supported_stack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_buildpack_binding_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_buildpack_binding_operations.py index b9a45d62628d..89a9f91c41ac 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_buildpack_binding_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_buildpack_binding_operations.py @@ -6,223 +6,230 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, buildpack_binding_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), - "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, buildpack_binding_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), - "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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, +def build_delete_request( resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, buildpack_binding_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), - "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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_request( - subscription_id: str, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, 'str'), - "builderName": _SERIALIZER.url("builder_name", builder_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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 BuildpackBindingOperations(object): - """BuildpackBindingOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BuildpackBindingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`buildpack_binding` 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( @@ -233,67 +240,74 @@ def get( builder_name: str, buildpack_binding_name: str, **kwargs: Any - ) -> "_models.BuildpackBindingResource": + ) -> _models.BuildpackBindingResource: """Get a buildpack binding by name. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildpackBindingResource, or the result of cls(response) + :return: BuildpackBindingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore def _create_or_update_initial( self, @@ -302,40 +316,56 @@ def _create_or_update_initial( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: Union[_models.BuildpackBindingResource, IO], **kwargs: Any - ) -> "_models.BuildpackBindingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] + ) -> _models.BuildpackBindingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(buildpack_binding, 'BuildpackBindingResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(buildpack_binding, (IO, bytes)): + _content = buildpack_binding + else: + _json = self._serialize.body(buildpack_binding, "BuildpackBindingResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -343,20 +373,19 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, @@ -364,25 +393,31 @@ def begin_create_or_update( build_service_name: str, builder_name: str, buildpack_binding_name: str, - buildpack_binding: "_models.BuildpackBindingResource", + buildpack_binding: _models.BuildpackBindingResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.BuildpackBindingResource"]: + ) -> LROPoller[_models.BuildpackBindingResource]: """Create or update a buildpack binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_name: str :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. :type buildpack_binding: ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -395,19 +430,114 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResource"] - 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, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. Is + either a model type or a IO type. Required. + :type buildpack_binding: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResource] + :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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + 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, service_name=service_name, build_service_name=build_service_name, @@ -416,32 +546,35 @@ def begin_create_or_update( buildpack_binding=buildpack_binding, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BuildpackBindingResource', pipeline_response) + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -452,33 +585,41 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements buildpack_binding_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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]: @@ -488,11 +629,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, service_name: str, @@ -504,15 +644,15 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Operation to delete a Buildpack Binding. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str - :param buildpack_binding_name: The name of the Buildpack Binding Name. + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. :type buildpack_binding_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. @@ -524,110 +664,124 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_name, buildpack_binding_name=buildpack_binding_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - build_service_name: str, - builder_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildpackBindingResourceCollection"]: + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> Iterable["_models.BuildpackBindingResource"]: """Handles requests to list all buildpack bindings in a builder. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param build_service_name: The name of the build service resource. + :param build_service_name: The name of the build service resource. Required. :type build_service_name: str - :param builder_name: The name of the builder resource. + :param builder_name: The name of the builder resource. Required. :type builder_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildpackBindingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either BuildpackBindingResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildpackBindingResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, build_service_name=build_service_name, builder_name=builder_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, - service_name=service_name, - build_service_name=build_service_name, - builder_name=builder_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -641,10 +795,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 @@ -654,8 +806,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_certificates_operations.py index 90a20d153441..edf084854b81 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_certificates_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_certificates_operations.py @@ -6,308 +6,317 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - 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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="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, - service_name: str, - certificate_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, service_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", 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.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'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 get( - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateResource": + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: """Get the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResource, or the result of cls(response) + :return: CertificateResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> "_models.CertificateResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] + ) -> _models.CertificateResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(certificate_resource, 'CertificateResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -315,21 +324,101 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -337,21 +426,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, certificate_name: str, - certificate_resource: "_models.CertificateResource", + certificate_resource: Union[_models.CertificateResource, IO], **kwargs: Any - ) -> LROPoller["_models.CertificateResource"]: + ) -> LROPoller[_models.CertificateResource]: """Create or update certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_name: str - :param certificate_resource: Parameters for the create or update operation. + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type certificate_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -364,84 +457,93 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, service_name=service_name, certificate_name=certificate_name, certificate_resource=certificate_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CertificateResource', pipeline_response) + deserialized = self._deserialize("CertificateResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, certificate_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, certificate_name=certificate_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]: @@ -451,25 +553,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - certificate_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the certificate resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param certificate_name: The name of the certificate resource. + :param certificate_name: The name of the certificate resource. Required. :type certificate_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. @@ -481,98 +578,115 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, certificate_name=certificate_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.CertificateResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.CertificateResource"]: """List all the certificates of one user. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateResourceCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,10 +700,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 @@ -599,8 +711,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_config_servers_operations.py index 38b579a33bbf..c4f7e47e1b5e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_config_servers_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_config_servers_operations.py @@ -6,311 +6,311 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_validate_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ConfigServersOperations(object): - """ConfigServersOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`config_servers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ConfigServerResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: """Get the config server and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigServerResource, or the result of cls(response) + :return: ConfigServerResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -318,37 +318,115 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -361,86 +439,107 @@ def begin_update_put( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> "_models.ConfigServerResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] + ) -> _models.ConfigServerResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_resource, 'ConfigServerResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -448,37 +547,115 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - config_server_resource: "_models.ConfigServerResource", + config_server_resource: Union[_models.ConfigServerResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerResource"]: + ) -> LROPoller[_models.ConfigServerResource]: """Update the config server. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_resource: Parameters for the update operation. + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. :type config_server_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -491,86 +668,107 @@ def begin_update_patch( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_resource=config_server_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerResource', pipeline_response) + deserialized = self._deserialize("ConfigServerResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore def _validate_initial( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> "_models.ConfigServerSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] + ) -> _models.ConfigServerSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(config_server_settings, 'ConfigServerSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -578,37 +776,115 @@ def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_validate( self, resource_group_name: str, service_name: str, - config_server_settings: "_models.ConfigServerSettings", + config_server_settings: Union[_models.ConfigServerSettings, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigServerSettingsValidateResult"]: + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: """Check if the config server settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param config_server_settings: Config server settings to be validated. + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. :type config_server_settings: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerSettings + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -621,47 +897,54 @@ def begin_validate( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigServerSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigServerSettingsValidateResult"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, config_server_settings=config_server_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigServerSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_configuration_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_configuration_services_operations.py index 3658e5a81456..e91fec31572e 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_configuration_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_configuration_services_operations.py @@ -6,354 +6,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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, - service_name: str, - configuration_service_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, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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, - service_name: str, - configuration_service_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, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - configuration_service_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_validate_request( + resource_group_name: str, service_name: str, configuration_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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 ConfigurationServicesOperations(object): - """ConfigurationServicesOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 ConfigurationServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`configuration_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any - ) -> "_models.ConfigurationServiceResource": + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> _models.ConfigurationServiceResource: """Get the Application Configuration Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigurationServiceResource, or the result of cls(response) + :return: ConfigurationServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] + ) -> _models.ConfigurationServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(configuration_service_resource, 'ConfigurationServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_service_resource, (IO, bytes)): + _content = configuration_service_resource + else: + _json = self._serialize.body(configuration_service_resource, "ConfigurationServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -361,18 +361,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: _models.ConfigurationServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -380,22 +462,26 @@ def begin_create_or_update( resource_group_name: str, service_name: str, configuration_service_name: str, - configuration_service_resource: "_models.ConfigurationServiceResource", + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigurationServiceResource"]: + ) -> LROPoller[_models.ConfigurationServiceResource]: """Create the default Application Configuration Service or update the existing Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param configuration_service_resource: Parameters for the update operation. + :param configuration_service_resource: Parameters for the update operation. Is either a model + type or a IO type. Required. :type configuration_service_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -408,84 +494,93 @@ def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + 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, service_name=service_name, configuration_service_name=configuration_service_name, configuration_service_resource=configuration_service_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceResource', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, configuration_service_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_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]: @@ -495,25 +590,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - configuration_service_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any ) -> LROPoller[None]: """Disable the default Application Configuration Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_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. @@ -525,98 +615,116 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, configuration_service_name=configuration_service_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.ConfigurationServiceResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.ConfigurationServiceResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationServiceResourceCollection or the - result of cls(response) + :return: An iterator like instance of either ConfigurationServiceResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -630,10 +738,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 @@ -643,49 +749,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore def _validate_initial( self, resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> "_models.ConfigurationServiceSettingsValidateResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] + ) -> _models.ConfigurationServiceSettingsValidateResult: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(settings, 'ConfigurationServiceSettings') - - request = build_validate_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(settings, (IO, bytes)): + _content = settings + else: + _json = self._serialize.body(settings, "ConfigurationServiceSettings") + + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_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]: @@ -693,18 +813,97 @@ def _validate_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: _models.ConfigurationServiceSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_validate( @@ -712,20 +911,25 @@ def begin_validate( resource_group_name: str, service_name: str, configuration_service_name: str, - settings: "_models.ConfigurationServiceSettings", + settings: Union[_models.ConfigurationServiceSettings, IO], **kwargs: Any - ) -> LROPoller["_models.ConfigurationServiceSettingsValidateResult"]: + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: """Check if the Application Configuration Service settings are valid. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param configuration_service_name: The name of Application Configuration Service. + :param configuration_service_name: The name of Application Configuration Service. Required. :type configuration_service_name: str - :param settings: Application Configuration Service settings to be validated. + :param settings: Application Configuration Service settings to be validated. Is either a model + type or a IO type. Required. :type settings: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettings + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -738,48 +942,55 @@ def begin_validate( ConfigurationServiceSettingsValidateResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ConfigurationServiceSettingsValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationServiceSettingsValidateResult"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + 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._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, configuration_service_name=configuration_service_name, settings=settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConfigurationServiceSettingsValidateResult', pipeline_response) + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_custom_domains_operations.py index 10105b150f93..767da0924cf9 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_custom_domains_operations.py @@ -6,330 +6,310 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, - service_name: str, - app_name: str, - domain_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, service_name: str, app_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class CustomDomainsOperations(object): - """CustomDomainsOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.CustomDomainResource": + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: """Get the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomainResource, or the result of cls(response) + :return: CustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _create_or_update_initial( self, @@ -337,39 +317,55 @@ def _create_or_update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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, 202]: @@ -377,21 +373,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -400,22 +481,27 @@ def begin_create_or_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Create or update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,19 +514,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -448,67 +536,73 @@ def begin_create_or_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, domain_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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]: @@ -518,28 +612,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - domain_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_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. @@ -551,46 +639,52 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, app_name=app_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore def _update_initial( self, @@ -598,39 +692,55 @@ def _update_initial( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> "_models.CustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] + ) -> _models.CustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_resource, 'CustomDomainResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, domain_name=domain_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 [200, 202]: @@ -638,18 +748,103 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -658,22 +853,27 @@ def begin_update( service_name: str, app_name: str, domain_name: str, - domain_resource: "_models.CustomDomainResource", + domain_resource: Union[_models.CustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomainResource"]: + ) -> LROPoller[_models.CustomDomainResource]: """Update custom domain of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param domain_name: The name of the custom domain resource. + :param domain_name: The name of the custom domain resource. Required. :type domain_name: str - :param domain_resource: Parameters for the create or update operation. + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. :type domain_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -686,19 +886,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, service_name=service_name, app_name=app_name, @@ -706,90 +908,103 @@ def begin_update( domain_resource=domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomainResource', pipeline_response) + deserialized = self._deserialize("CustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - app_name: str, - **kwargs: Any - ) -> Iterable["_models.CustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.CustomDomainResource"]: """List the custom domains of one lifecycle application. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type 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 CustomDomainResourceCollection or the result of + :return: An iterator like instance of either CustomDomainResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -803,10 +1018,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 @@ -816,8 +1029,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_deployments_operations.py index 910bf1d888e0..827de002fb47 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_deployments_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_deployments_operations.py @@ -6,678 +6,667 @@ # Code generated 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, List, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_delete_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, +def build_update_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_for_cluster_request( - subscription_id: str, resource_group_name: str, service_name: str, + subscription_id: str, *, version: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 version is not None: - _query_parameters['version'] = [_SERIALIZER.query("version", q, 'str') if q is not None else '' for q in version] + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] # 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_start_request_initial( - subscription_id: str, +def build_start_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_stop_request_initial( - subscription_id: str, +def build_stop_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request_initial( - subscription_id: str, +def build_restart_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_get_log_file_url_request( - subscription_id: str, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_generate_heap_dump_request_initial( - subscription_id: str, +def build_generate_heap_dump_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_generate_thread_dump_request_initial( - subscription_id: str, +def build_generate_thread_dump_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_start_jfr_request_initial( - subscription_id: str, +def build_start_jfr_request( resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "appName": _SERIALIZER.url("app_name", app_name, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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 DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentResource": + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: """Get a Deployment and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentResource, or the result of cls(response) + :return: DeploymentResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( self, @@ -685,39 +674,55 @@ def _create_or_update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, 202]: @@ -725,21 +730,107 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -748,23 +839,27 @@ def begin_create_or_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Create a new Deployment or update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the create or update operation. + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -777,19 +872,21 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -797,67 +894,73 @@ def begin_create_or_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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]: @@ -867,28 +970,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Operation to delete a Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -900,46 +997,52 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore def _update_initial( self, @@ -947,39 +1050,55 @@ def _update_initial( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> "_models.DeploymentResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] + ) -> _models.DeploymentResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(deployment_resource, 'DeploymentResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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 [200, 202]: @@ -987,18 +1106,104 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -1007,23 +1212,27 @@ def begin_update( service_name: str, app_name: str, deployment_name: str, - deployment_resource: "_models.DeploymentResource", + deployment_resource: Union[_models.DeploymentResource, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentResource"]: + ) -> LROPoller[_models.DeploymentResource]: """Operation to update an exiting Deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param deployment_resource: Parameters for the update operation. + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. :type deployment_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1036,19 +1245,21 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, service_name=service_name, app_name=app_name, @@ -1056,32 +1267,35 @@ def begin_update( deployment_resource=deployment_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentResource', pipeline_response) + deserialized = self._deserialize("DeploymentResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore @distributed_trace def list( @@ -1091,60 +1305,72 @@ def list( app_name: str, version: Optional[List[str]] = None, **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + ) -> Iterable["_models.DeploymentResource"]: """Handles requests to list all resources in an App. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, app_name=app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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, - service_name=service_name, - app_name=app_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1158,10 +1384,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 @@ -1171,69 +1395,76 @@ 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore @distributed_trace def list_for_cluster( - self, - resource_group_name: str, - service_name: str, - version: Optional[List[str]] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentResourceCollection"]: + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentResource"]: """List deployments for a certain service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :param version: Version of the deployments to be listed. Default value is None. :type version: list[str] :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentResourceCollection or the result of - cls(response) + :return: An iterator like instance of either DeploymentResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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_for_cluster_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - api_version=api_version, + subscription_id=self._config.subscription_id, version=version, - template_url=self.list_for_cluster.metadata['url'], + api_version=api_version, + template_url=self.list_for_cluster.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_for_cluster_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - api_version=api_version, - version=version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1247,10 +1478,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 @@ -1260,46 +1489,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1309,28 +1539,22 @@ def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Start the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1342,81 +1566,90 @@ def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1426,28 +1659,22 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Stop the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1459,81 +1686,90 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, app_name: str, deployment_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata['url'], + template_url=self._restart_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]: @@ -1543,28 +1779,22 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace - def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any + def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Restart the deployment. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_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. @@ -1576,98 +1806,107 @@ def begin_restart( # 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore @distributed_trace def get_log_file_url( - self, - resource_group_name: str, - service_name: str, - app_name: str, - deployment_name: str, - **kwargs: Any - ) -> Optional["_models.LogFileUrlResponse"]: + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: """Get deployment log file URL. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogFileUrlResponse, or the result of cls(response) + :return: LogFileUrlResponse or None or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.LogFileUrlResponse or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogFileUrlResponse"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] - request = build_get_log_file_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_file_url.metadata['url'], + template_url=self.get_log_file_url.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]: @@ -1676,15 +1915,14 @@ def get_log_file_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('LogFileUrlResponse', pipeline_response) + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_file_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore - + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1692,39 +1930,55 @@ def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statemen service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_heap_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_heap_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_heap_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_heap_dump_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]: @@ -1734,33 +1988,119 @@ def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _generate_heap_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + _generate_heap_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + @overload + def begin_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_heap_dump( # pylint: disable=inconsistent-return-statements + def begin_generate_heap_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Generate Heap Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1771,19 +2111,21 @@ def begin_generate_heap_dump( # 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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._generate_heap_dump_initial( + raw_result = self._generate_heap_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1791,29 +2133,33 @@ def begin_generate_heap_dump( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **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_generate_heap_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + begin_generate_heap_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statements self, @@ -1821,39 +2167,55 @@ def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statem service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_generate_thread_dump_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_thread_dump_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_thread_dump_initial.metadata['url'], + content=_content, + template_url=self._generate_thread_dump_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]: @@ -1863,33 +2225,119 @@ def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _generate_thread_dump_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + _generate_thread_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + @overload + def begin_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_thread_dump( # pylint: disable=inconsistent-return-statements + def begin_generate_thread_dump( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Generate Thread Dump. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1900,19 +2348,21 @@ def begin_generate_thread_dump( # pylint: disable=inconsistent-return-statement 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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._generate_thread_dump_initial( + raw_result = self._generate_thread_dump_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -1920,29 +2370,33 @@ def begin_generate_thread_dump( # pylint: disable=inconsistent-return-statement diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **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_generate_thread_dump.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + begin_generate_thread_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore def _start_jfr_initial( # pylint: disable=inconsistent-return-statements self, @@ -1950,39 +2404,55 @@ def _start_jfr_initial( # pylint: disable=inconsistent-return-statements service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(diagnostic_parameters, 'DiagnosticParameters') - - request = build_start_jfr_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_start_jfr_request( resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._start_jfr_initial.metadata['url'], + content=_content, + template_url=self._start_jfr_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]: @@ -1992,33 +2462,119 @@ def _start_jfr_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_jfr_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + _start_jfr_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + @overload + def begin_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_start_jfr( # pylint: disable=inconsistent-return-statements + def begin_start_jfr( self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, - diagnostic_parameters: "_models.DiagnosticParameters", + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Start JFR. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param app_name: The name of the App resource. + :param app_name: The name of the App resource. Required. :type app_name: str - :param deployment_name: The name of the Deployment resource. + :param deployment_name: The name of the Deployment resource. Required. :type deployment_name: str - :param diagnostic_parameters: Parameters for the diagnostic operation. + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. :type diagnostic_parameters: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters + ~azure.mgmt.appplatform.v2022_05_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2029,19 +2585,21 @@ def begin_start_jfr( # 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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._start_jfr_initial( + raw_result = self._start_jfr_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, app_name=app_name, @@ -2049,26 +2607,30 @@ def begin_start_jfr( # pylint: disable=inconsistent-return-statements diagnostic_parameters=diagnostic_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, 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, lro_options={'final-state-via': 'azure-async-operation'}, **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_start_jfr.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + begin_start_jfr.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_gateway_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_gateway_custom_domains_operations.py index a0520c689f06..30124705bb2c 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_gateway_custom_domains_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_gateway_custom_domains_operations.py @@ -6,282 +6,287 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, +def build_create_or_update_request( resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, +def build_delete_request( resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewayCustomDomainsOperations(object): - """GatewayCustomDomainsOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class GatewayCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`gateway_custom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.GatewayCustomDomainResource": + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any + ) -> _models.GatewayCustomDomainResource: """Get the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayCustomDomainResource, or the result of cls(response) + :return: GatewayCustomDomainResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore def _create_or_update_initial( self, @@ -289,39 +294,55 @@ def _create_or_update_initial( service_name: str, gateway_name: str, domain_name: str, - gateway_custom_domain_resource: "_models.GatewayCustomDomainResource", + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], **kwargs: Any - ) -> "_models.GatewayCustomDomainResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] + ) -> _models.GatewayCustomDomainResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_custom_domain_resource, 'GatewayCustomDomainResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_custom_domain_resource, (IO, bytes)): + _content = gateway_custom_domain_resource + else: + _json = self._serialize.body(gateway_custom_domain_resource, "GatewayCustomDomainResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: @@ -329,18 +350,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: _models.GatewayCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayCustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayCustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -349,24 +458,27 @@ def begin_create_or_update( service_name: str, gateway_name: str, domain_name: str, - gateway_custom_domain_resource: "_models.GatewayCustomDomainResource", + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], **kwargs: Any - ) -> LROPoller["_models.GatewayCustomDomainResource"]: + ) -> LROPoller[_models.GatewayCustomDomainResource]: """Create or update the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_name: str :param gateway_custom_domain_resource: The gateway custom domain resource for the create or - update operation. + update operation. Is either a model type or a IO type. Required. :type gateway_custom_domain_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -379,19 +491,21 @@ def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + 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, service_name=service_name, gateway_name=gateway_name, @@ -399,67 +513,73 @@ def begin_create_or_update( gateway_custom_domain_resource=gateway_custom_domain_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayCustomDomainResource', pipeline_response) + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_name: str, domain_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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]: @@ -469,28 +589,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - domain_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the Spring Cloud Gateway custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param domain_name: The name of the Spring Cloud Gateway custom domain. + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. :type domain_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. @@ -502,104 +616,120 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, gateway_name=gateway_name, domain_name=domain_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> Iterable["_models.GatewayCustomDomainResourceCollection"]: + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> Iterable["_models.GatewayCustomDomainResource"]: """Handle requests to list all Spring Cloud Gateway custom domains. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayCustomDomainResourceCollection or the - result of cls(response) + :return: An iterator like instance of either GatewayCustomDomainResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCustomDomainResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, gateway_name=gateway_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, - service_name=service_name, - gateway_name=gateway_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -613,10 +743,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 @@ -626,8 +754,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_gateway_route_configs_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_gateway_route_configs_operations.py index 28ff32b2f6a7..ca1b06739944 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_gateway_route_configs_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_gateway_route_configs_operations.py @@ -6,282 +6,287 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "routeConfigName": _SERIALIZER.url("route_config_name", route_config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_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_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "routeConfigName": _SERIALIZER.url("route_config_name", route_config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_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_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), - "routeConfigName": _SERIALIZER.url("route_config_name", route_config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_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="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewayRouteConfigsOperations(object): - """GatewayRouteConfigsOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class GatewayRouteConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`gateway_route_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 get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any - ) -> "_models.GatewayRouteConfigResource": + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any + ) -> _models.GatewayRouteConfigResource: """Get the Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayRouteConfigResource, or the result of cls(response) + :return: GatewayRouteConfigResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore def _create_or_update_initial( self, @@ -289,39 +294,55 @@ def _create_or_update_initial( service_name: str, gateway_name: str, route_config_name: str, - gateway_route_config_resource: "_models.GatewayRouteConfigResource", + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], **kwargs: Any - ) -> "_models.GatewayRouteConfigResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] + ) -> _models.GatewayRouteConfigResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_route_config_resource, 'GatewayRouteConfigResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_route_config_resource, (IO, bytes)): + _content = gateway_route_config_resource + else: + _json = self._serialize.body(gateway_route_config_resource, "GatewayRouteConfigResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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]: @@ -329,18 +350,108 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: _models.GatewayRouteConfigResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayRouteConfigResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayRouteConfigResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -349,25 +460,28 @@ def begin_create_or_update( service_name: str, gateway_name: str, route_config_name: str, - gateway_route_config_resource: "_models.GatewayRouteConfigResource", + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], **kwargs: Any - ) -> LROPoller["_models.GatewayRouteConfigResource"]: + ) -> LROPoller[_models.GatewayRouteConfigResource]: """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_name: str :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or - update operation. + update operation. Is either a model type or a IO type. Required. :type gateway_route_config_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -380,19 +494,21 @@ def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + 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, service_name=service_name, gateway_name=gateway_name, @@ -400,67 +516,73 @@ def begin_create_or_update( gateway_route_config_resource=gateway_route_config_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayRouteConfigResource', pipeline_response) + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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]: @@ -470,28 +592,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - route_config_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the Spring Cloud Gateway route config. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param route_config_name: The name of the Spring Cloud Gateway route config. + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. :type route_config_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. @@ -503,104 +619,120 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, gateway_name=gateway_name, route_config_name=route_config_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> Iterable["_models.GatewayRouteConfigResourceCollection"]: + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> Iterable["_models.GatewayRouteConfigResource"]: """Handle requests to list all Spring Cloud Gateway route configs. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayRouteConfigResourceCollection or the result - of cls(response) + :return: An iterator like instance of either GatewayRouteConfigResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayRouteConfigResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_name, gateway_name=gateway_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, - service_name=service_name, - gateway_name=gateway_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -614,10 +746,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 @@ -627,8 +757,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_gateways_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_gateways_operations.py index e609f3734870..31337eabfe99 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_gateways_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_gateways_operations.py @@ -6,354 +6,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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, - service_name: str, - gateway_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, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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, - service_name: str, - gateway_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, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_domain_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - gateway_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewaysOperations(object): - """GatewaysOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 GatewaysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`gateways` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any - ) -> "_models.GatewayResource": + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> _models.GatewayResource: """Get the Spring Cloud Gateway and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayResource, or the result of cls(response) + :return: GatewayResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, gateway_name: str, - gateway_resource: "_models.GatewayResource", + gateway_resource: Union[_models.GatewayResource, IO], **kwargs: Any - ) -> "_models.GatewayResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] + ) -> _models.GatewayResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(gateway_resource, 'GatewayResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_resource, (IO, bytes)): + _content = gateway_resource + else: + _json = self._serialize.body(gateway_resource, "GatewayResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: @@ -361,18 +361,97 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: _models.GatewayResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -380,20 +459,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, gateway_name: str, - gateway_resource: "_models.GatewayResource", + gateway_resource: Union[_models.GatewayResource, IO], **kwargs: Any - ) -> LROPoller["_models.GatewayResource"]: + ) -> LROPoller[_models.GatewayResource]: """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param gateway_resource: The gateway for the create or update operation. - :type gateway_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource + :param gateway_resource: The gateway for the create or update operation. Is either a model type + or a IO type. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -406,84 +490,93 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + 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, service_name=service_name, gateway_name=gateway_name, gateway_resource=gateway_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GatewayResource', pipeline_response) + deserialized = self._deserialize("GatewayResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, gateway_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_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]: @@ -493,25 +586,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any ) -> LROPoller[None]: """Disable the default Spring Cloud Gateway. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_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. @@ -523,98 +611,113 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, gateway_name=gateway_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.GatewayResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.GatewayResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayResourceCollection or the result of - cls(response) + :return: An iterator like instance of either GatewayResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -628,10 +731,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 @@ -641,79 +742,159 @@ 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.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore - @distributed_trace + @overload def validate_domain( self, resource_group_name: str, service_name: str, gateway_name: str, - validate_payload: "_models.CustomDomainValidatePayload", + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CustomDomainValidateResult": + ) -> _models.CustomDomainValidateResult: """Check the domains are valid as well as not in use. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param gateway_name: The name of Spring Cloud Gateway. + :param gateway_name: The name of Spring Cloud Gateway. Required. :type gateway_name: str - :param validate_payload: Custom domain payload to be validated. + :param validate_payload: Custom domain payload to be validated. Required. :type validate_payload: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult, or the result of cls(response) + :return: CustomDomainValidateResult or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(validate_payload, 'CustomDomainValidatePayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") request = build_validate_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, gateway_name=gateway_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_domain.metadata['url'], + content=_content, + template_url=self.validate_domain.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomainValidateResult', pipeline_response) + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore - + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_monitoring_settings_operations.py index 568d1ddf5556..202f316245f3 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_monitoring_settings_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_monitoring_settings_operations.py @@ -6,267 +6,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request_initial( - subscription_id: str, - resource_group_name: str, - service_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_update_put_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **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_update_patch_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 MonitoringSettingsOperations(object): - """MonitoringSettingsOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`monitoring_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.MonitoringSettingResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.MonitoringSettingResource: """Get the Monitoring Setting and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringSettingResource, or the result of cls(response) + :return: MonitoringSettingResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_put_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_put_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_put_initial.metadata['url'], + content=_content, + template_url=self._update_put_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]: @@ -274,37 +282,115 @@ def _update_put_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_put( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -317,86 +403,107 @@ def begin_update_put( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( + raw_result = self._update_put_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore def _update_patch_initial( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> "_models.MonitoringSettingResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] + ) -> _models.MonitoringSettingResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitoring_setting_resource, 'MonitoringSettingResource') - - request = build_update_patch_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_patch_initial.metadata['url'], + content=_content, + template_url=self._update_patch_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]: @@ -404,37 +511,115 @@ def _update_patch_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_patch_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_patch( self, resource_group_name: str, service_name: str, - monitoring_setting_resource: "_models.MonitoringSettingResource", + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], **kwargs: Any - ) -> LROPoller["_models.MonitoringSettingResource"]: + ) -> LROPoller[_models.MonitoringSettingResource]: """Update the Monitoring Setting. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param monitoring_setting_resource: Parameters for the update operation. + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. :type monitoring_setting_resource: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource + ~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation 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,47 +632,52 @@ def begin_update_patch( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.MonitoringSettingResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringSettingResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( + raw_result = self._update_patch_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, monitoring_setting_resource=monitoring_setting_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('MonitoringSettingResource', pipeline_response) + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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_patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + begin_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_operations.py index c40577622568..e896a3a0cd7f 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_operations.py @@ -6,111 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - accept = "application/json" +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'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 REST API operations of the Microsoft.AppPlatform provider. :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.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,10 +147,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 +158,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.AppPlatform/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_runtime_versions_operations.py index b099daba7235..0465b05a7230 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_runtime_versions_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_runtime_versions_operations.py @@ -6,117 +6,128 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from 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 -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_runtime_versions_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - accept = "application/json" +def build_list_runtime_versions_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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/runtimeVersions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 RuntimeVersionsOperations(object): - """RuntimeVersionsOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`runtime_versions` 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_runtime_versions( - self, - **kwargs: Any - ) -> "_models.AvailableRuntimeVersions": + def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AvailableRuntimeVersions, or the result of cls(response) + :return: AvailableRuntimeVersions or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.AvailableRuntimeVersions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableRuntimeVersions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] - request = build_list_runtime_versions_request( api_version=api_version, - template_url=self.list_runtime_versions.metadata['url'], + template_url=self.list_runtime_versions.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AvailableRuntimeVersions', pipeline_response) + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_runtime_versions.metadata = {'url': "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore - + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_service_registries_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_service_registries_operations.py index d3a04dd5738d..032fbe32adce 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_service_registries_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_service_registries_operations.py @@ -6,294 +6,297 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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, - service_name: str, - service_registry_name: str, - **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, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + _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, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ServiceRegistriesOperations(object): - """ServiceRegistriesOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServiceRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`service_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: """Get the Service Registry and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceRegistryResource, or the result of cls(response) + :return: ServiceRegistryResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> "_models.ServiceRegistryResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._create_or_update_initial.metadata['url'], + 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]: @@ -301,35 +304,30 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any - ) -> LROPoller["_models.ServiceRegistryResource"]: + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> LROPoller[_models.ServiceRegistryResource]: """Create the default Service Registry or update the existing Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -343,81 +341,90 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceRegistryResource', pipeline_response) + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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]: @@ -427,25 +434,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - service_registry_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any ) -> LROPoller[None]: """Disable the default Service Registry. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param service_registry_name: The name of Service Registry. + :param service_registry_name: The name of Service Registry. Required. :type service_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -457,98 +459,116 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, service_registry_name=service_registry_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.ServiceRegistryResourceCollection"]: + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.ServiceRegistryResource"]: """Handles requests to list all resources in a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceRegistryResourceCollection or the result of + :return: An iterator like instance of either ServiceRegistryResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceRegistryResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceRegistryResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -562,10 +582,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 @@ -575,8 +593,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_services_operations.py index 7bd2702945ca..b9eec6087d55 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_services_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_services_operations.py @@ -6,636 +6,594 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, service_name: str, 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, - service_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, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_test_keys_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_regenerate_test_key_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/regenerateTestKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_disable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_enable_test_endpoint_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_stop_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_stop_request(resource_group_name: str, service_name: str, 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_start_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_check_name_availability_request( - subscription_id: str, - location: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "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 - ) - - -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 ServicesOperations(object): - """ServicesOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ServiceResource": + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: """Get a Service and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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, 202]: @@ -643,39 +601,43 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Create a new Service or update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the create or update operation. + :param resource: Parameters for the create or update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -688,81 +650,160 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - 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, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] + :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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_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]: @@ -772,22 +813,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Operation to delete a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -799,80 +834,98 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore def _update_initial( - self, - resource_group_name: str, - service_name: str, - resource: "_models.ServiceResource", - **kwargs: Any - ) -> "_models.ServiceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(resource, 'ServiceResource') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( resource_group_name=resource_group_name, service_name=service_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 [200, 202]: @@ -880,36 +933,40 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, service_name: str, - resource: "_models.ServiceResource", + resource: _models.ServiceResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ServiceResource"]: + ) -> LROPoller[_models.ServiceResource]: """Operation to update an exiting Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param resource: Parameters for the update operation. + :param resource: Parameters for the update operation. Required. :type resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -922,220 +979,377 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] + :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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, service_name=service_name, resource=resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore @distributed_trace - def list_test_keys( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """List test keys for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_list_test_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_test_keys.metadata['url'], + template_url=self.list_test_keys.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_test_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_test_key( self, resource_group_name: str, service_name: str, - regenerate_test_key_request: "_models.RegenerateTestKeyRequestPayload", + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], **kwargs: Any - ) -> "_models.TestKeys": + ) -> _models.TestKeys: """Regenerate a test key for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param regenerate_test_key_request: Parameters for the operation. + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. :type regenerate_test_key_request: - ~azure.mgmt.appplatform.v2022_05_01_preview.models.RegenerateTestKeyRequestPayload + ~azure.mgmt.appplatform.v2022_05_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_test_key_request, 'RegenerateTestKeyRequestPayload') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") request = build_regenerate_test_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_test_key.metadata['url'], + content=_content, + template_url=self.regenerate_test_key.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_test_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore - + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore @distributed_trace def disable_test_endpoint( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: """Disable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.disable_test_endpoint.metadata['url'], + template_url=self.disable_test_endpoint.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]: @@ -1145,98 +1359,104 @@ def disable_test_endpoint( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - disable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore - + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore @distributed_trace - def enable_test_endpoint( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.TestKeys": + def enable_test_endpoint(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: """Enable test endpoint functionality for a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestKeys, or the result of cls(response) + :return: TestKeys or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.TestKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] - request = build_enable_test_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_test_endpoint.metadata['url'], + template_url=self.enable_test_endpoint.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestKeys', pipeline_response) + deserialized = self._deserialize("TestKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - enable_test_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore - + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1246,22 +1466,16 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_stop(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Stop a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -1273,75 +1487,86 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) 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]: @@ -1351,22 +1576,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_start(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Start a Service. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_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. @@ -1378,147 +1597,227 @@ def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_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, lro_options={'final-state-via': 'azure-async-operation'}, **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_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore - @distributed_trace + @overload def check_name_availability( self, location: str, - availability_parameters: "_models.NameAvailabilityParameters", + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param availability_parameters: Parameters supplied to the operation. + :param availability_parameters: Parameters supplied to the operation. Required. :type availability_parameters: ~azure.mgmt.appplatform.v2022_05_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_05_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(availability_parameters, 'NameAvailabilityParameters') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1532,10 +1831,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 @@ -1545,58 +1842,68 @@ 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.AppPlatform/Spring"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ServiceResourceList"]: + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResourceList or the result of cls(response) + :return: An iterator like instance of either ServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, + 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, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1610,10 +1917,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 @@ -1623,8 +1928,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_skus_operations.py index a49de3f263fc..94d43bc38aac 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_skus_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_skus_operations.py @@ -6,120 +6,140 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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 SkusOperations(object): - """SkusOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`skus` 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.ResourceSkuCollection"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceSku"]: """Lists all of the available skus of the Microsoft.AppPlatform provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuCollection or the result of - cls(response) + :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceSkuCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -133,10 +153,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 @@ -146,8 +164,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': "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_storages_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_storages_operations.py index ec3d2a798010..ce984ae5f649 100644 --- a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_storages_operations.py +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_05_01_preview/operations/_storages_operations.py @@ -6,308 +6,317 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - service_name: str, - storage_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, service_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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.AppPlatform/Spring/{serviceName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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') - - 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, - service_name: str, - storage_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, service_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 - ) - - -def build_list_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 StoragesOperations(object): - """StoragesOperations 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.appplatform.v2022_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class StoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_05_01_preview.AppPlatformManagementClient`'s + :attr:`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 get( - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any - ) -> "_models.StorageResource": + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> _models.StorageResource: """Get the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageResource, or the result of cls(response) + :return: StorageResource or the result of cls(response) :rtype: ~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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-05-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> "_models.StorageResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] + ) -> _models.StorageResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(storage_resource, 'StorageResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + error_map.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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_resource, (IO, bytes)): + _content = storage_resource + else: + _json = self._serialize.body(storage_resource, "StorageResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_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_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, 202]: @@ -315,21 +324,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: _models.StorageResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -337,20 +425,25 @@ def begin_create_or_update( resource_group_name: str, service_name: str, storage_name: str, - storage_resource: "_models.StorageResource", + storage_resource: Union[_models.StorageResource, IO], **kwargs: Any - ) -> LROPoller["_models.StorageResource"]: + ) -> LROPoller[_models.StorageResource]: """Create or update storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_name: str - :param storage_resource: Parameters for the create or update operation. - :type storage_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource + :param storage_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -363,84 +456,93 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResource"] - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + 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, service_name=service_name, storage_name=storage_name, storage_resource=storage_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('StorageResource', pipeline_response) + deserialized = self._deserialize("StorageResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + self, resource_group_name: str, service_name: str, storage_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-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, storage_name=storage_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]: @@ -450,25 +552,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - storage_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the storage resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str - :param storage_name: The name of the storage resource. + :param storage_name: The name of the storage resource. Required. :type storage_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. @@ -480,98 +577,113 @@ 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-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + 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, service_name=service_name, storage_name=storage_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, lro_options={'final-state-via': 'azure-async-operation'}, **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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Iterable["_models.StorageResourceCollection"]: + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.StorageResource"]: """List all the storages of one Azure Spring Apps resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param service_name: The name of the Service resource. + :param service_name: The name of the Service resource. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageResourceCollection or the result of - cls(response) + :return: An iterator like instance of either StorageResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_05_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01-preview") # 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", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResourceCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageResourceCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, service_name=service_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, - service_name=service_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -585,10 +697,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 @@ -598,8 +708,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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/__init__.py new file mode 100644 index 000000000000..a6bfaa2de14d --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/__init__.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._app_platform_management_client import AppPlatformManagementClient +from ._version import VERSION + +__version__ = VERSION + +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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_app_platform_management_client.py new file mode 100644 index 000000000000..952f3a0527e6 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_app_platform_management_client.py @@ -0,0 +1,221 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from .._serialization import Deserializer, Serializer +from ._configuration import AppPlatformManagementClientConfiguration +from .operations import ( + ApiPortalCustomDomainsOperations, + ApiPortalsOperations, + AppsOperations, + BindingsOperations, + BuildServiceAgentPoolOperations, + BuildServiceBuilderOperations, + BuildServiceOperations, + BuildpackBindingOperations, + CertificatesOperations, + ConfigServersOperations, + ConfigurationServicesOperations, + CustomDomainsOperations, + DeploymentsOperations, + GatewayCustomDomainsOperations, + GatewayRouteConfigsOperations, + GatewaysOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServiceRegistriesOperations, + ServicesOperations, + SkusOperations, + StoragesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """REST API for Azure Spring Apps. + + :ivar services: ServicesOperations operations + :vartype services: azure.mgmt.appplatform.v2022_09_01_preview.operations.ServicesOperations + :ivar config_servers: ConfigServersOperations operations + :vartype config_servers: + azure.mgmt.appplatform.v2022_09_01_preview.operations.ConfigServersOperations + :ivar configuration_services: ConfigurationServicesOperations operations + :vartype configuration_services: + azure.mgmt.appplatform.v2022_09_01_preview.operations.ConfigurationServicesOperations + :ivar service_registries: ServiceRegistriesOperations operations + :vartype service_registries: + azure.mgmt.appplatform.v2022_09_01_preview.operations.ServiceRegistriesOperations + :ivar build_service: BuildServiceOperations operations + :vartype build_service: + azure.mgmt.appplatform.v2022_09_01_preview.operations.BuildServiceOperations + :ivar buildpack_binding: BuildpackBindingOperations operations + :vartype buildpack_binding: + azure.mgmt.appplatform.v2022_09_01_preview.operations.BuildpackBindingOperations + :ivar build_service_builder: BuildServiceBuilderOperations operations + :vartype build_service_builder: + azure.mgmt.appplatform.v2022_09_01_preview.operations.BuildServiceBuilderOperations + :ivar build_service_agent_pool: BuildServiceAgentPoolOperations operations + :vartype build_service_agent_pool: + azure.mgmt.appplatform.v2022_09_01_preview.operations.BuildServiceAgentPoolOperations + :ivar monitoring_settings: MonitoringSettingsOperations operations + :vartype monitoring_settings: + azure.mgmt.appplatform.v2022_09_01_preview.operations.MonitoringSettingsOperations + :ivar apps: AppsOperations operations + :vartype apps: azure.mgmt.appplatform.v2022_09_01_preview.operations.AppsOperations + :ivar bindings: BindingsOperations operations + :vartype bindings: azure.mgmt.appplatform.v2022_09_01_preview.operations.BindingsOperations + :ivar storages: StoragesOperations operations + :vartype storages: azure.mgmt.appplatform.v2022_09_01_preview.operations.StoragesOperations + :ivar certificates: CertificatesOperations operations + :vartype certificates: + azure.mgmt.appplatform.v2022_09_01_preview.operations.CertificatesOperations + :ivar custom_domains: CustomDomainsOperations operations + :vartype custom_domains: + azure.mgmt.appplatform.v2022_09_01_preview.operations.CustomDomainsOperations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: + azure.mgmt.appplatform.v2022_09_01_preview.operations.DeploymentsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.appplatform.v2022_09_01_preview.operations.Operations + :ivar runtime_versions: RuntimeVersionsOperations operations + :vartype runtime_versions: + azure.mgmt.appplatform.v2022_09_01_preview.operations.RuntimeVersionsOperations + :ivar skus: SkusOperations operations + :vartype skus: azure.mgmt.appplatform.v2022_09_01_preview.operations.SkusOperations + :ivar gateways: GatewaysOperations operations + :vartype gateways: azure.mgmt.appplatform.v2022_09_01_preview.operations.GatewaysOperations + :ivar gateway_route_configs: GatewayRouteConfigsOperations operations + :vartype gateway_route_configs: + azure.mgmt.appplatform.v2022_09_01_preview.operations.GatewayRouteConfigsOperations + :ivar gateway_custom_domains: GatewayCustomDomainsOperations operations + :vartype gateway_custom_domains: + azure.mgmt.appplatform.v2022_09_01_preview.operations.GatewayCustomDomainsOperations + :ivar api_portals: ApiPortalsOperations operations + :vartype api_portals: + azure.mgmt.appplatform.v2022_09_01_preview.operations.ApiPortalsOperations + :ivar api_portal_custom_domains: ApiPortalCustomDomainsOperations operations + :vartype api_portal_custom_domains: + azure.mgmt.appplatform.v2022_09_01_preview.operations.ApiPortalCustomDomainsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. 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-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AppPlatformManagementClientConfiguration( + 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.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_services = ConfigurationServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_registries = ServiceRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service = BuildServiceOperations(self._client, self._config, self._serialize, self._deserialize) + self.buildpack_binding = BuildpackBindingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_builder = BuildServiceBuilderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_agent_pool = BuildServiceAgentPoolOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) + self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.storages = StoragesOperations(self._client, self._config, self._serialize, self._deserialize) + self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateways = GatewaysOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_route_configs = GatewayRouteConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gateway_custom_domains = GatewayCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_portals = ApiPortalsOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_portal_custom_domains = ApiPortalCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AppPlatformManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_configuration.py new file mode 100644 index 000000000000..82f9d68386a6 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_configuration.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import sys +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class AppPlatformManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for AppPlatformManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-09-01-preview") # type: Literal["2022-09-01-preview"] + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_metadata.json b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_metadata.json new file mode 100644 index 000000000000..d5d9a8097a25 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_metadata.json @@ -0,0 +1,124 @@ +{ + "chosen_version": "2022-09-01-preview", + "total_api_version_list": ["2022-09-01-preview"], + "client": { + "name": "AppPlatformManagementClient", + "filename": "_app_platform_management_client", + "description": "REST API for Azure Spring Apps.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", + "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: str = \"https://management.azure.com\",", + "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": { + "services": "ServicesOperations", + "config_servers": "ConfigServersOperations", + "configuration_services": "ConfigurationServicesOperations", + "service_registries": "ServiceRegistriesOperations", + "build_service": "BuildServiceOperations", + "buildpack_binding": "BuildpackBindingOperations", + "build_service_builder": "BuildServiceBuilderOperations", + "build_service_agent_pool": "BuildServiceAgentPoolOperations", + "monitoring_settings": "MonitoringSettingsOperations", + "apps": "AppsOperations", + "bindings": "BindingsOperations", + "storages": "StoragesOperations", + "certificates": "CertificatesOperations", + "custom_domains": "CustomDomainsOperations", + "deployments": "DeploymentsOperations", + "operations": "Operations", + "runtime_versions": "RuntimeVersionsOperations", + "skus": "SkusOperations", + "gateways": "GatewaysOperations", + "gateway_route_configs": "GatewayRouteConfigsOperations", + "gateway_custom_domains": "GatewayCustomDomainsOperations", + "api_portals": "ApiPortalsOperations", + "api_portal_custom_domains": "ApiPortalCustomDomainsOperations" + } +} diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_vendor.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_version.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_version.py new file mode 100644 index 000000000000..92453d8691d9 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "6.1.0" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/__init__.py new file mode 100644 index 000000000000..398c48287ad8 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._app_platform_management_client import AppPlatformManagementClient + +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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/_app_platform_management_client.py new file mode 100644 index 000000000000..2e98dc6d5d90 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/_app_platform_management_client.py @@ -0,0 +1,218 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ..._serialization import Deserializer, Serializer +from ._configuration import AppPlatformManagementClientConfiguration +from .operations import ( + ApiPortalCustomDomainsOperations, + ApiPortalsOperations, + AppsOperations, + BindingsOperations, + BuildServiceAgentPoolOperations, + BuildServiceBuilderOperations, + BuildServiceOperations, + BuildpackBindingOperations, + CertificatesOperations, + ConfigServersOperations, + ConfigurationServicesOperations, + CustomDomainsOperations, + DeploymentsOperations, + GatewayCustomDomainsOperations, + GatewayRouteConfigsOperations, + GatewaysOperations, + MonitoringSettingsOperations, + Operations, + RuntimeVersionsOperations, + ServiceRegistriesOperations, + ServicesOperations, + SkusOperations, + StoragesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """REST API for Azure Spring Apps. + + :ivar services: ServicesOperations operations + :vartype services: azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.ServicesOperations + :ivar config_servers: ConfigServersOperations operations + :vartype config_servers: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.ConfigServersOperations + :ivar configuration_services: ConfigurationServicesOperations operations + :vartype configuration_services: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.ConfigurationServicesOperations + :ivar service_registries: ServiceRegistriesOperations operations + :vartype service_registries: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.ServiceRegistriesOperations + :ivar build_service: BuildServiceOperations operations + :vartype build_service: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.BuildServiceOperations + :ivar buildpack_binding: BuildpackBindingOperations operations + :vartype buildpack_binding: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.BuildpackBindingOperations + :ivar build_service_builder: BuildServiceBuilderOperations operations + :vartype build_service_builder: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.BuildServiceBuilderOperations + :ivar build_service_agent_pool: BuildServiceAgentPoolOperations operations + :vartype build_service_agent_pool: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.BuildServiceAgentPoolOperations + :ivar monitoring_settings: MonitoringSettingsOperations operations + :vartype monitoring_settings: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.MonitoringSettingsOperations + :ivar apps: AppsOperations operations + :vartype apps: azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.AppsOperations + :ivar bindings: BindingsOperations operations + :vartype bindings: azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.BindingsOperations + :ivar storages: StoragesOperations operations + :vartype storages: azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.StoragesOperations + :ivar certificates: CertificatesOperations operations + :vartype certificates: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.CertificatesOperations + :ivar custom_domains: CustomDomainsOperations operations + :vartype custom_domains: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.CustomDomainsOperations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.DeploymentsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.Operations + :ivar runtime_versions: RuntimeVersionsOperations operations + :vartype runtime_versions: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.RuntimeVersionsOperations + :ivar skus: SkusOperations operations + :vartype skus: azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.SkusOperations + :ivar gateways: GatewaysOperations operations + :vartype gateways: azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.GatewaysOperations + :ivar gateway_route_configs: GatewayRouteConfigsOperations operations + :vartype gateway_route_configs: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.GatewayRouteConfigsOperations + :ivar gateway_custom_domains: GatewayCustomDomainsOperations operations + :vartype gateway_custom_domains: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.GatewayCustomDomainsOperations + :ivar api_portals: ApiPortalsOperations operations + :vartype api_portals: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.ApiPortalsOperations + :ivar api_portal_custom_domains: ApiPortalCustomDomainsOperations operations + :vartype api_portal_custom_domains: + azure.mgmt.appplatform.v2022_09_01_preview.aio.operations.ApiPortalCustomDomainsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. 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-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AppPlatformManagementClientConfiguration( + 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.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_services = ConfigurationServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_registries = ServiceRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service = BuildServiceOperations(self._client, self._config, self._serialize, self._deserialize) + self.buildpack_binding = BuildpackBindingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_builder = BuildServiceBuilderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_agent_pool = BuildServiceAgentPoolOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) + self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.storages = StoragesOperations(self._client, self._config, self._serialize, self._deserialize) + self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateways = GatewaysOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_route_configs = GatewayRouteConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gateway_custom_domains = GatewayCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_portals = ApiPortalsOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_portal_custom_domains = ApiPortalCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AppPlatformManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..c1bfbffcb4ca --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/_configuration.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import sys +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AppPlatformManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for AppPlatformManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-09-01-preview") # type: Literal["2022-09-01-preview"] + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..57694a8d82f6 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/__init__.py @@ -0,0 +1,63 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._services_operations import ServicesOperations +from ._config_servers_operations import ConfigServersOperations +from ._configuration_services_operations import ConfigurationServicesOperations +from ._service_registries_operations import ServiceRegistriesOperations +from ._build_service_operations import BuildServiceOperations +from ._buildpack_binding_operations import BuildpackBindingOperations +from ._build_service_builder_operations import BuildServiceBuilderOperations +from ._build_service_agent_pool_operations import BuildServiceAgentPoolOperations +from ._monitoring_settings_operations import MonitoringSettingsOperations +from ._apps_operations import AppsOperations +from ._bindings_operations import BindingsOperations +from ._storages_operations import StoragesOperations +from ._certificates_operations import CertificatesOperations +from ._custom_domains_operations import CustomDomainsOperations +from ._deployments_operations import DeploymentsOperations +from ._operations import Operations +from ._runtime_versions_operations import RuntimeVersionsOperations +from ._skus_operations import SkusOperations +from ._gateways_operations import GatewaysOperations +from ._gateway_route_configs_operations import GatewayRouteConfigsOperations +from ._gateway_custom_domains_operations import GatewayCustomDomainsOperations +from ._api_portals_operations import ApiPortalsOperations +from ._api_portal_custom_domains_operations import ApiPortalCustomDomainsOperations + +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__ = [ + "ServicesOperations", + "ConfigServersOperations", + "ConfigurationServicesOperations", + "ServiceRegistriesOperations", + "BuildServiceOperations", + "BuildpackBindingOperations", + "BuildServiceBuilderOperations", + "BuildServiceAgentPoolOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "StoragesOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", + "GatewaysOperations", + "GatewayRouteConfigsOperations", + "GatewayCustomDomainsOperations", + "ApiPortalsOperations", + "ApiPortalCustomDomainsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_api_portal_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_api_portal_custom_domains_operations.py new file mode 100644 index 000000000000..5ed51e1585ca --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_api_portal_custom_domains_operations.py @@ -0,0 +1,605 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._api_portal_custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApiPortalCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`api_portal_custom_domains` 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, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any + ) -> _models.ApiPortalCustomDomainResource: + """Get the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiPortalCustomDomainResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], + **kwargs: Any + ) -> _models.ApiPortalCustomDomainResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_custom_domain_resource, (IO, bytes)): + _content = api_portal_custom_domain_resource + else: + _json = self._serialize.body(api_portal_custom_domain_resource, "ApiPortalCustomDomainResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: _models.ApiPortalCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Is either a model type or a IO type. Required. + :type api_portal_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + 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, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_name, + api_portal_custom_domain_resource=api_portal_custom_domain_resource, + 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("ApiPortalCustomDomainResource", 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApiPortalCustomDomainResource"]: + """Handle requests to list all API portal custom domains. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiPortalCustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResourceCollection] + + 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, + service_name=service_name, + api_portal_name=api_portal_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiPortalCustomDomainResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_api_portals_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_api_portals_operations.py new file mode 100644 index 000000000000..ea8a12916485 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_api_portals_operations.py @@ -0,0 +1,733 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._api_portals_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApiPortalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`api_portals` 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, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> _models.ApiPortalResource: + """Get the API portal and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiPortalResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiPortalResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: Union[_models.ApiPortalResource, IO], + **kwargs: Any + ) -> _models.ApiPortalResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_resource, (IO, bytes)): + _content = api_portal_resource + else: + _json = self._serialize.body(api_portal_resource, "ApiPortalResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApiPortalResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApiPortalResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: _models.ApiPortalResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: Union[_models.ApiPortalResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Is either a + model type or a IO type. Required. + :type api_portal_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + 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, + service_name=service_name, + api_portal_name=api_portal_name, + api_portal_resource=api_portal_resource, + 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("ApiPortalResource", 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, api_portal_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the default API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + api_portal_name=api_portal_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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApiPortalResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiPortalResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiPortalResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") + + request = build_validate_domain_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate_domain.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_apps_operations.py new file mode 100644 index 000000000000..c2379fa79bcd --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_apps_operations.py @@ -0,0 +1,1290 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._apps_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_get_resource_upload_url_request, + build_list_request, + build_set_active_deployments_request, + build_update_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`apps` 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, + resource_group_name: str, + service_name: str, + app_name: str, + sync_status: Optional[str] = None, + **kwargs: Any + ) -> _models.AppResource: + """Get an App and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param sync_status: Indicates whether sync status. Default value is None. + :type sync_status: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AppResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + sync_status=sync_status, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> _models.AppResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, + service_name=service_name, + app_name=app_name, + app_resource=app_resource, + 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("AppResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Operation to delete an App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + app_name=app_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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> _models.AppResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + app_resource=app_resource, + 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("AppResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncIterable["_models.AppResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AppResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AppResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + + @distributed_trace_async + async def get_resource_upload_url( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: + """Get an resource upload URL for an App, which may be artifacts or source archive. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceUploadDefinition or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceUploadDefinition + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] + + request = build_get_resource_upload_url_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_resource_upload_url.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + + async def _set_active_deployments_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], + **kwargs: Any + ) -> _models.AppResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(active_deployment_collection, (IO, bytes)): + _content = active_deployment_collection + else: + _json = self._serialize.body(active_deployment_collection, "ActiveDeploymentCollection") + + request = build_set_active_deployments_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._set_active_deployments_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _set_active_deployments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + + @overload + async def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: _models.ActiveDeploymentCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ActiveDeploymentCollection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Is either a model + type or a IO type. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ActiveDeploymentCollection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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._set_active_deployments_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + active_deployment_collection=active_deployment_collection, + 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("AppResource", 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_set_active_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") + + request = build_validate_domain_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate_domain.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_bindings_operations.py new file mode 100644 index 000000000000..699024c8ef2f --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_bindings_operations.py @@ -0,0 +1,857 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._bindings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`bindings` 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, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: + """Get a Binding and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BindingResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> _models.BindingResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, + service_name=service_name, + app_name=app_name, + binding_name=binding_name, + binding_resource=binding_resource, + 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("BindingResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, binding_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Operation to delete a Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + app_name=app_name, + binding_name=binding_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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> _models.BindingResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_name, + binding_resource=binding_resource, + 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("BindingResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BindingResource"]: + """Handles requests to list all resources in an App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type 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 BindingResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] + + 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, + service_name=service_name, + app_name=app_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BindingResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_build_service_agent_pool_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_build_service_agent_pool_operations.py new file mode 100644 index 000000000000..5053293fce44 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_build_service_agent_pool_operations.py @@ -0,0 +1,482 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._build_service_agent_pool_operations import ( + build_get_request, + build_list_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BuildServiceAgentPoolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service_agent_pool` 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, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildServiceAgentPoolResource"]: + """List build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildServiceAgentPoolResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResourceCollection] + + 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, + service_name=service_name, + build_service_name=build_service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BuildServiceAgentPoolResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: + """Get build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildServiceAgentPoolResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + agent_pool_name=agent_pool_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + + async def _update_put_initial( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], + **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(agent_pool_resource, (IO, bytes)): + _content = agent_pool_resource + else: + _json = self._serialize.body(agent_pool_resource, "BuildServiceAgentPoolResource") + + request = build_update_put_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_put_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: _models.BuildServiceAgentPoolResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + 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_put_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + agent_pool_name=agent_pool_name, + agent_pool_resource=agent_pool_resource, + 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("BuildServiceAgentPoolResource", 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_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_build_service_builder_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_build_service_builder_operations.py new file mode 100644 index 000000000000..1e1e4b74ef07 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_build_service_builder_operations.py @@ -0,0 +1,671 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._build_service_builder_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_deployments_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BuildServiceBuilderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service_builder` 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, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.BuilderResource: + """Get a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuilderResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuilderResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: Union[_models.BuilderResource, IO], + **kwargs: Any + ) -> _models.BuilderResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(builder_resource, (IO, bytes)): + _content = builder_resource + else: + _json = self._serialize.body(builder_resource, "BuilderResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BuilderResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BuilderResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: _models.BuilderResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: Union[_models.BuilderResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Is either a + model type or a IO type. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + builder_resource=builder_resource, + 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("BuilderResource", 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, build_service_name: str, builder_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuilderResource"]: + """List KPack builders result. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuilderResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResourceCollection] + + 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, + service_name=service_name, + build_service_name=build_service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BuilderResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore + + @distributed_trace_async + async def list_deployments( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.DeploymentList: + """List deployments that are using the builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentList or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentList + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentList] + + request = build_list_deployments_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_deployments.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeploymentList", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/listUsingDeployments"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_build_service_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_build_service_operations.py new file mode 100644 index 000000000000..e7e1e154b4d8 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_build_service_operations.py @@ -0,0 +1,1147 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.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._build_service_operations import ( + build_create_or_update_build_request, + build_get_build_request, + build_get_build_result_log_request, + build_get_build_result_request, + build_get_build_service_request, + build_get_resource_upload_url_request, + build_get_supported_buildpack_request, + build_get_supported_stack_request, + build_list_build_results_request, + build_list_build_services_request, + build_list_builds_request, + build_list_supported_buildpacks_request, + build_list_supported_stacks_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BuildServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service` 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_build_services( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildService"]: + """List build services resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildService or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildService] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceCollection] + + 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_build_services_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_build_services.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BuildServiceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_build_services.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore + + @distributed_trace_async + async def get_build_service( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.BuildService: + """Get a build service resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildService or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildService + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildService] + + request = build_get_build_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build_service.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildService", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore + + @distributed_trace + def list_builds( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Build"]: + """List KPack builds. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Build or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.Build] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildCollection] + + 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_builds_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_builds.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BuildCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_builds.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore + + @distributed_trace_async + async def get_build( + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> _models.Build: + """Get a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Build + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] + + request = build_get_build_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Build", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + + @overload + async def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: _models.Build, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Build + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: Union[_models.Build, IO], + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type build: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Build or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Build + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build, (IO, bytes)): + _content = build + else: + _json = self._serialize.body(build, "Build") + + request = build_create_or_update_build_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_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_build.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Build", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Build", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + + @distributed_trace + def list_build_results( + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildResult"]: + """List KPack build results. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildResult] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultCollection] + + 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_build_results_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_build_results.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BuildResultCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_build_results.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore + + @distributed_trace_async + async def get_build_result( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build_result_name: str, + **kwargs: Any + ) -> _models.BuildResult: + """Get a KPack build result. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build_result_name: The name of the build result resource. Required. + :type build_result_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildResult + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResult] + + request = build_get_build_result_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + build_result_name=build_result_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build_result.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore + + @distributed_trace_async + async def get_build_result_log( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build_result_name: str, + **kwargs: Any + ) -> _models.BuildResultLog: + """Get a KPack build result log download URL. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build_result_name: The name of the build result resource. Required. + :type build_result_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildResultLog or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildResultLog + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultLog] + + request = build_get_build_result_log_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + build_result_name=build_result_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build_result_log.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildResultLog", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build_result_log.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore + + @distributed_trace_async + async def get_resource_upload_url( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: + """Get an resource upload URL for build service, which may be artifacts or source archive. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceUploadDefinition or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceUploadDefinition + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] + + request = build_get_resource_upload_url_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_resource_upload_url.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore + + @distributed_trace_async + async def list_supported_buildpacks( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedBuildpacksCollection: + """Get all supported buildpacks. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedBuildpacksCollection or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedBuildpacksCollection + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpacksCollection] + + request = build_list_supported_buildpacks_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_supported_buildpacks.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedBuildpacksCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_supported_buildpacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore + + @distributed_trace_async + async def get_supported_buildpack( + self, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, **kwargs: Any + ) -> _models.SupportedBuildpackResource: + """Get the supported buildpack resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param buildpack_name: The name of the buildpack resource. Required. + :type buildpack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedBuildpackResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedBuildpackResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpackResource] + + request = build_get_supported_buildpack_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + buildpack_name=buildpack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_supported_buildpack.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedBuildpackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_supported_buildpack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore + + @distributed_trace_async + async def list_supported_stacks( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedStacksCollection: + """Get all supported stacks. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedStacksCollection or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedStacksCollection + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStacksCollection] + + request = build_list_supported_stacks_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_supported_stacks.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedStacksCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_supported_stacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore + + @distributed_trace_async + async def get_supported_stack( + self, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, **kwargs: Any + ) -> _models.SupportedStackResource: + """Get the supported stack resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param stack_name: The name of the stack resource. Required. + :type stack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedStackResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedStackResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStackResource] + + request = build_get_supported_stack_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + stack_name=stack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_supported_stack.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedStackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_supported_stack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_buildpack_binding_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_buildpack_binding_operations.py new file mode 100644 index 000000000000..a08fb9a77249 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_buildpack_binding_operations.py @@ -0,0 +1,645 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._buildpack_binding_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BuildpackBindingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`buildpack_binding` 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, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + **kwargs: Any + ) -> _models.BuildpackBindingResource: + """Get a buildpack binding by name. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildpackBindingResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> _models.BuildpackBindingResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(buildpack_binding, (IO, bytes)): + _content = buildpack_binding + else: + _json = self._serialize.body(buildpack_binding, "BuildpackBindingResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: _models.BuildpackBindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildpackBindingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildpackBindingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. Is + either a model type or a IO type. Required. + :type buildpack_binding: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildpackBindingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_name, + buildpack_binding=buildpack_binding, + 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("BuildpackBindingResource", 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Operation to delete a Buildpack Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildpackBindingResource"]: + """Handles requests to list all buildpack bindings in a builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResourceCollection] + + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BuildpackBindingResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_certificates_operations.py new file mode 100644 index 000000000000..81bda509ce44 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_certificates_operations.py @@ -0,0 +1,583 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`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_async + async def get( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: + """Get the certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: Union[_models.CertificateResource, IO], + **kwargs: Any + ) -> _models.CertificateResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_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_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: Union[_models.CertificateResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, + service_name=service_name, + certificate_name=certificate_name, + certificate_resource=certificate_resource, + 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("CertificateResource", 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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, certificate_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + certificate_name=certificate_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + certificate_name=certificate_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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CertificateResource"]: + """List all the certificates of one user. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CertificateResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CertificateResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_config_servers_operations.py new file mode 100644 index 000000000000..795eed11c654 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_config_servers_operations.py @@ -0,0 +1,813 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._config_servers_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`config_servers` 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, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: + """Get the config server and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigServerResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + async def _update_put_initial( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> _models.ConfigServerResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_put_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + config_server_resource=config_server_resource, + 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("ConfigServerResource", 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_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + async def _update_patch_initial( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> _models.ConfigServerResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_patch_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + config_server_resource=config_server_resource, + 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("ConfigServerResource", 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_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + async def _validate_initial( + self, + resource_group_name: str, + service_name: str, + config_server_settings: Union[_models.ConfigServerSettings, IO], + **kwargs: Any + ) -> _models.ConfigServerSettingsValidateResult: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._validate_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: Union[_models.ConfigServerSettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerSettingsValidateResult] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + config_server_settings=config_server_settings, + 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("ConfigServerSettingsValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_configuration_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_configuration_services_operations.py new file mode 100644 index 000000000000..ddafa8d411ac --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_configuration_services_operations.py @@ -0,0 +1,827 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._configuration_services_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConfigurationServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`configuration_services` 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, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> _models.ConfigurationServiceResource: + """Get the Application Configuration Service and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationServiceResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], + **kwargs: Any + ) -> _models.ConfigurationServiceResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_service_resource, (IO, bytes)): + _content = configuration_service_resource + else: + _json = self._serialize.body(configuration_service_resource, "ConfigurationServiceResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: _models.ConfigurationServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Is either a model + type or a IO type. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + 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, + service_name=service_name, + configuration_service_name=configuration_service_name, + configuration_service_resource=configuration_service_resource, + 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("ConfigurationServiceResource", 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, configuration_service_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Disable the default Application Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + configuration_service_name=configuration_service_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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationServiceResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConfigurationServiceResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ConfigurationServiceResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore + + async def _validate_initial( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: Union[_models.ConfigurationServiceSettings, IO], + **kwargs: Any + ) -> _models.ConfigurationServiceSettingsValidateResult: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(settings, (IO, bytes)): + _content = settings + else: + _json = self._serialize.body(settings, "ConfigurationServiceSettings") + + request = build_validate_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._validate_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: _models.ConfigurationServiceSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: Union[_models.ConfigurationServiceSettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Is either a model + type or a IO type. Required. + :type settings: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceSettings + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceSettingsValidateResult] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + 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._validate_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_name, + settings=settings, + 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("ConfigurationServiceSettingsValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_custom_domains_operations.py new file mode 100644 index 000000000000..f2ebdcc2411e --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_custom_domains_operations.py @@ -0,0 +1,858 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`custom_domains` 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, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: + """Get the custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CustomDomainResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> _models.CustomDomainResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, + service_name=service_name, + app_name=app_name, + domain_name=domain_name, + domain_resource=domain_resource, + 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("CustomDomainResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, domain_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + app_name=app_name, + domain_name=domain_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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> _models.CustomDomainResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_name, + domain_resource=domain_resource, + 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("CustomDomainResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CustomDomainResource"]: + """List the custom domains of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type 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 CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] + + 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, + service_name=service_name, + app_name=app_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CustomDomainResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_deployments_operations.py new file mode 100644 index 000000000000..b34a64a81a69 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_deployments_operations.py @@ -0,0 +1,2571 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._deployments_operations import ( + build_create_or_update_request, + build_delete_request, + build_disable_remote_debugging_request, + build_enable_remote_debugging_request, + build_generate_heap_dump_request, + build_generate_thread_dump_request, + build_get_log_file_url_request, + build_get_remote_debugging_config_request, + build_get_request, + build_list_for_cluster_request, + build_list_request, + build_restart_request, + build_start_jfr_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`deployments` 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, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: + """Get a Deployment and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> _models.DeploymentResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + deployment_resource=deployment_resource, + 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("DeploymentResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Operation to delete a Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> _models.DeploymentResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + deployment_resource=deployment_resource, + 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("DeploymentResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + app_name: str, + version: Optional[List[str]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.DeploymentResource"]: + """Handles requests to list all resources in an App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param version: Version of the deployments to be listed. Default value is None. + :type version: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] + + 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, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + version=version, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeploymentResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + + @distributed_trace + def list_for_cluster( + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentResource"]: + """List deployments for a certain service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param version: Version of the deployments to be listed. Default value is None. + :type version: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] + + 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_for_cluster_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + version=version, + api_version=api_version, + template_url=self.list_for_cluster.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeploymentResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + + async def _start_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._start_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + + @distributed_trace_async + async def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start the deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._start_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + + async def _stop_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._stop_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + + @distributed_trace_async + async def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Stop the deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._stop_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + + async def _restart_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._restart_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + + @distributed_trace_async + async def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restart the deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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._restart_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + + async def _enable_remote_debugging_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[Union[_models.RemoteDebuggingPayload, IO]] = None, + **kwargs: Any + ) -> _models.RemoteDebugging: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(remote_debugging_payload, (IO, bytes)): + _content = remote_debugging_payload + else: + if remote_debugging_payload is not None: + _json = self._serialize.body(remote_debugging_payload, "RemoteDebuggingPayload") + else: + _json = None + + request = build_enable_remote_debugging_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._enable_remote_debugging_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _enable_remote_debugging_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/enableRemoteDebugging"} # type: ignore + + @overload + async def begin_enable_remote_debugging( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[_models.RemoteDebuggingPayload] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RemoteDebugging]: + """Enable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param remote_debugging_payload: Parameters for enable remote debugging. Default value is None. + :type remote_debugging_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.RemoteDebuggingPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.RemoteDebugging] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_enable_remote_debugging( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RemoteDebugging]: + """Enable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param remote_debugging_payload: Parameters for enable remote debugging. Default value is None. + :type remote_debugging_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.RemoteDebugging] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_enable_remote_debugging( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[Union[_models.RemoteDebuggingPayload, IO]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.RemoteDebugging]: + """Enable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param remote_debugging_payload: Parameters for enable remote debugging. Is either a model type + or a IO type. Default value is None. + :type remote_debugging_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.RemoteDebuggingPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.RemoteDebugging] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + 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._enable_remote_debugging_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + remote_debugging_payload=remote_debugging_payload, + 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("RemoteDebugging", 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_enable_remote_debugging.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/enableRemoteDebugging"} # type: ignore + + async def _disable_remote_debugging_initial( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.RemoteDebugging: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + + request = build_disable_remote_debugging_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._disable_remote_debugging_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _disable_remote_debugging_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/disableRemoteDebugging"} # type: ignore + + @distributed_trace_async + async def begin_disable_remote_debugging( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.RemoteDebugging]: + """Disable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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 RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.RemoteDebugging] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + 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._disable_remote_debugging_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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): + deserialized = self._deserialize("RemoteDebugging", 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_disable_remote_debugging.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/disableRemoteDebugging"} # type: ignore + + @distributed_trace_async + async def get_remote_debugging_config( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.RemoteDebugging: + """Get remote debugging config. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RemoteDebugging or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.RemoteDebugging + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + + request = build_get_remote_debugging_config_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_remote_debugging_config.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_remote_debugging_config.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getRemoteDebuggingConfig"} # type: ignore + + @distributed_trace_async + async def get_log_file_url( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: + """Get deployment log file URL. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogFileUrlResponse or None or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.LogFileUrlResponse or 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] + + request = build_get_log_file_url_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_log_file_url.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore + + async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_heap_dump_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._generate_heap_dump_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _generate_heap_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + + @overload + async def begin_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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._generate_heap_dump_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + diagnostic_parameters=diagnostic_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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_generate_heap_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + + async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_thread_dump_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._generate_thread_dump_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _generate_thread_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + @overload + async def begin_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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._generate_thread_dump_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + diagnostic_parameters=diagnostic_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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_generate_thread_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_start_jfr_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._start_jfr_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_jfr_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + + @overload + async def begin_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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._start_jfr_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + diagnostic_parameters=diagnostic_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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_start_jfr.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_gateway_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_gateway_custom_domains_operations.py new file mode 100644 index 000000000000..6567878db247 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_gateway_custom_domains_operations.py @@ -0,0 +1,605 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._gateway_custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GatewayCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateway_custom_domains` 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, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any + ) -> _models.GatewayCustomDomainResource: + """Get the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayCustomDomainResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], + **kwargs: Any + ) -> _models.GatewayCustomDomainResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_custom_domain_resource, (IO, bytes)): + _content = gateway_custom_domain_resource + else: + _json = self._serialize.body(gateway_custom_domain_resource, "GatewayCustomDomainResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: _models.GatewayCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Is either a model type or a IO type. Required. + :type gateway_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + 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, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_name, + gateway_custom_domain_resource=gateway_custom_domain_resource, + 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("GatewayCustomDomainResource", 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, gateway_name: str, domain_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayCustomDomainResource"]: + """Handle requests to list all Spring Cloud Gateway custom domains. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayCustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResourceCollection] + + 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, + service_name=service_name, + gateway_name=gateway_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GatewayCustomDomainResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_gateway_route_configs_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_gateway_route_configs_operations.py new file mode 100644 index 000000000000..8a0bce77cbba --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_gateway_route_configs_operations.py @@ -0,0 +1,608 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._gateway_route_configs_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GatewayRouteConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateway_route_configs` 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, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any + ) -> _models.GatewayRouteConfigResource: + """Get the Spring Cloud Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayRouteConfigResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], + **kwargs: Any + ) -> _models.GatewayRouteConfigResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_route_config_resource, (IO, bytes)): + _content = gateway_route_config_resource + else: + _json = self._serialize.body(gateway_route_config_resource, "GatewayRouteConfigResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: _models.GatewayRouteConfigResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayRouteConfigResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayRouteConfigResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Is either a model type or a IO type. Required. + :type gateway_route_config_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayRouteConfigResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + 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, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_name, + gateway_route_config_resource=gateway_route_config_resource, + 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("GatewayRouteConfigResource", 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the Spring Cloud Gateway route config. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayRouteConfigResource"]: + """Handle requests to list all Spring Cloud Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayRouteConfigResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResourceCollection] + + 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, + service_name=service_name, + gateway_name=gateway_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GatewayRouteConfigResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_gateways_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_gateways_operations.py new file mode 100644 index 000000000000..7c17ce081af2 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_gateways_operations.py @@ -0,0 +1,733 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._gateways_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GatewaysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateways` 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, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> _models.GatewayResource: + """Get the Spring Cloud Gateway and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GatewayResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: Union[_models.GatewayResource, IO], + **kwargs: Any + ) -> _models.GatewayResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_resource, (IO, bytes)): + _content = gateway_resource + else: + _json = self._serialize.body(gateway_resource, "GatewayResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GatewayResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GatewayResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: _models.GatewayResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: Union[_models.GatewayResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Is either a model type + or a IO type. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + 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, + service_name=service_name, + gateway_name=gateway_name, + gateway_resource=gateway_resource, + 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("GatewayResource", 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, gateway_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Disable the default Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + gateway_name=gateway_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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GatewayResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") + + request = build_validate_domain_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate_domain.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_monitoring_settings_operations.py new file mode 100644 index 000000000000..efb66f7f3319 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_monitoring_settings_operations.py @@ -0,0 +1,583 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._monitoring_settings_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`monitoring_settings` 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, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.MonitoringSettingResource: + """Get the Monitoring Setting and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + async def _update_put_initial( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> _models.MonitoringSettingResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_put_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + monitoring_setting_resource=monitoring_setting_resource, + 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("MonitoringSettingResource", 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_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + async def _update_patch_initial( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> _models.MonitoringSettingResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_patch_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + monitoring_setting_resource=monitoring_setting_resource, + 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("MonitoringSettingResource", 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_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_operations.py new file mode 100644 index 000000000000..3f38cdf700a9 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_operations.py @@ -0,0 +1,139 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDetail"]: + """Lists all of the available REST API operations of the Microsoft.AppPlatform provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationDetail or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.OperationDetail] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableOperations] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AvailableOperations", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_runtime_versions_operations.py new file mode 100644 index 000000000000..69ee49fbee1a --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_runtime_versions_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. +# -------------------------------------------------------------------------- +import sys +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._runtime_versions_operations import build_list_runtime_versions_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`runtime_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: + """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AvailableRuntimeVersions or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AvailableRuntimeVersions + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] + + request = build_list_runtime_versions_request( + api_version=api_version, + template_url=self.list_runtime_versions.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_service_registries_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_service_registries_operations.py new file mode 100644 index 000000000000..0831e2fd300a --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_service_registries_operations.py @@ -0,0 +1,468 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._service_registries_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ServiceRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`service_registries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: + """Get the Service Registry and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param service_registry_name: The name of Service Registry. Required. + :type service_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServiceRegistryResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceRegistryResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + async def _create_or_update_initial( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceRegistryResource]: + """Create the default Service Registry or update the existing Service Registry. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param service_registry_name: The name of Service Registry. Required. + :type service_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceRegistryResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceRegistryResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + 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, + service_name=service_name, + service_registry_name=service_registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ServiceRegistryResource", 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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Disable the default Service Registry. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param service_registry_name: The name of Service Registry. Required. + :type service_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + service_registry_name=service_registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServiceRegistryResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServiceRegistryResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceRegistryResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceRegistryResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_services_operations.py new file mode 100644 index 000000000000..987b75c4ca36 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_services_operations.py @@ -0,0 +1,1523 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._services_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_disable_test_endpoint_request, + build_enable_test_endpoint_request, + build_get_request, + build_list_by_subscription_request, + build_list_request, + build_list_test_keys_request, + build_regenerate_test_key_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`services` 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, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: + """Get a Service and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServiceResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + async def _create_or_update_initial( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + resource: _models.ServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, + service_name=service_name, + resource=resource, + 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("ServiceResource", 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.AppPlatform/Spring/{serviceName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Operation to delete a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_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.AppPlatform/Spring/{serviceName}"} # type: ignore + + async def _update_initial( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: _models.ServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + resource=resource, + 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("ServiceResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @distributed_trace_async + async def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: + """List test keys for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.TestKeys + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + request = build_list_test_keys_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_test_keys.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.TestKeys + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") + + request = build_regenerate_test_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.regenerate_test_key.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore + + @distributed_trace_async + async def disable_test_endpoint( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + """Disable test endpoint functionality for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_disable_test_endpoint_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.disable_test_endpoint.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore + + @distributed_trace_async + async def enable_test_endpoint( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.TestKeys: + """Enable test endpoint functionality for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.TestKeys + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + request = build_enable_test_endpoint_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.enable_test_endpoint.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore + + async def _stop_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._stop_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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + + @distributed_trace_async + async def begin_stop(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Stop a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._stop_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_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_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + + async def _start_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._start_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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + + @distributed_trace_async + async def begin_start(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Start a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._start_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_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_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + + @overload + async def check_name_availability( + self, + location: str, + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.NameAvailability + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") + + request = build_check_name_availability_request( + location=location, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NameAvailability", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: + """Handles requests to list all resources in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServiceResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] + + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceResourceList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: + """Handles requests to list all resources in a resource group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] + + 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, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceResourceList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_skus_operations.py new file mode 100644 index 000000000000..b4fa8f741a94 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_skus_operations.py @@ -0,0 +1,140 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._skus_operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`skus` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceSku"]: + """Lists all of the available skus of the Microsoft.AppPlatform provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceSku or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSku] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceSkuCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_storages_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_storages_operations.py new file mode 100644 index 000000000000..d3e628baf7be --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/aio/operations/_storages_operations.py @@ -0,0 +1,582 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._storages_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class StoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.aio.AppPlatformManagementClient`'s + :attr:`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 get( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> _models.StorageResource: + """Get the storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: Union[_models.StorageResource, IO], + **kwargs: Any + ) -> _models.StorageResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_resource, (IO, bytes)): + _content = storage_resource + else: + _json = self._serialize.body(storage_resource, "StorageResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_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_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("StorageResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("StorageResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("StorageResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: _models.StorageResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: Union[_models.StorageResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + 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, + service_name=service_name, + storage_name=storage_name, + storage_resource=storage_resource, + 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("StorageResource", 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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, storage_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + storage_name=storage_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + storage_name=storage_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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageResource"]: + """List all the storages of one Azure Spring Apps resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StorageResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/models/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/models/__init__.py new file mode 100644 index 000000000000..4411039a50d3 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/models/__init__.py @@ -0,0 +1,459 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import ActiveDeploymentCollection +from ._models_py3 import ApiPortalCustomDomainProperties +from ._models_py3 import ApiPortalCustomDomainResource +from ._models_py3 import ApiPortalCustomDomainResourceCollection +from ._models_py3 import ApiPortalInstance +from ._models_py3 import ApiPortalProperties +from ._models_py3 import ApiPortalResource +from ._models_py3 import ApiPortalResourceCollection +from ._models_py3 import ApiPortalResourceRequests +from ._models_py3 import AppResource +from ._models_py3 import AppResourceCollection +from ._models_py3 import AppResourceProperties +from ._models_py3 import AppVNetAddons +from ._models_py3 import ApplicationInsightsAgentVersions +from ._models_py3 import AvailableOperations +from ._models_py3 import AvailableRuntimeVersions +from ._models_py3 import AzureFileVolume +from ._models_py3 import BindingResource +from ._models_py3 import BindingResourceCollection +from ._models_py3 import BindingResourceProperties +from ._models_py3 import Build +from ._models_py3 import BuildCollection +from ._models_py3 import BuildProperties +from ._models_py3 import BuildResourceRequests +from ._models_py3 import BuildResult +from ._models_py3 import BuildResultCollection +from ._models_py3 import BuildResultLog +from ._models_py3 import BuildResultProperties +from ._models_py3 import BuildResultUserSourceInfo +from ._models_py3 import BuildService +from ._models_py3 import BuildServiceAgentPoolProperties +from ._models_py3 import BuildServiceAgentPoolResource +from ._models_py3 import BuildServiceAgentPoolResourceCollection +from ._models_py3 import BuildServiceAgentPoolSizeProperties +from ._models_py3 import BuildServiceCollection +from ._models_py3 import BuildServiceProperties +from ._models_py3 import BuildServicePropertiesResourceRequests +from ._models_py3 import BuildStageProperties +from ._models_py3 import BuilderProperties +from ._models_py3 import BuilderResource +from ._models_py3 import BuilderResourceCollection +from ._models_py3 import BuildpackBindingLaunchProperties +from ._models_py3 import BuildpackBindingProperties +from ._models_py3 import BuildpackBindingResource +from ._models_py3 import BuildpackBindingResourceCollection +from ._models_py3 import BuildpackProperties +from ._models_py3 import BuildpacksGroupProperties +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificateResource +from ._models_py3 import CertificateResourceCollection +from ._models_py3 import CloudErrorBody +from ._models_py3 import ClusterResourceProperties +from ._models_py3 import ConfigServerGitProperty +from ._models_py3 import ConfigServerProperties +from ._models_py3 import ConfigServerResource +from ._models_py3 import ConfigServerSettings +from ._models_py3 import ConfigServerSettingsErrorRecord +from ._models_py3 import ConfigServerSettingsValidateResult +from ._models_py3 import ConfigurationServiceGitProperty +from ._models_py3 import ConfigurationServiceGitPropertyValidateResult +from ._models_py3 import ConfigurationServiceGitRepository +from ._models_py3 import ConfigurationServiceInstance +from ._models_py3 import ConfigurationServiceProperties +from ._models_py3 import ConfigurationServiceResource +from ._models_py3 import ConfigurationServiceResourceCollection +from ._models_py3 import ConfigurationServiceResourceRequests +from ._models_py3 import ConfigurationServiceSettings +from ._models_py3 import ConfigurationServiceSettingsValidateResult +from ._models_py3 import ContainerProbeSettings +from ._models_py3 import ContentCertificateProperties +from ._models_py3 import CustomContainer +from ._models_py3 import CustomContainerUserSourceInfo +from ._models_py3 import CustomDomainProperties +from ._models_py3 import CustomDomainResource +from ._models_py3 import CustomDomainResourceCollection +from ._models_py3 import CustomDomainValidatePayload +from ._models_py3 import CustomDomainValidateResult +from ._models_py3 import CustomPersistentDiskProperties +from ._models_py3 import CustomPersistentDiskResource +from ._models_py3 import DeploymentInstance +from ._models_py3 import DeploymentList +from ._models_py3 import DeploymentResource +from ._models_py3 import DeploymentResourceCollection +from ._models_py3 import DeploymentResourceProperties +from ._models_py3 import DeploymentSettings +from ._models_py3 import DiagnosticParameters +from ._models_py3 import Error +from ._models_py3 import ExecAction +from ._models_py3 import GatewayApiMetadataProperties +from ._models_py3 import GatewayApiRoute +from ._models_py3 import GatewayCorsProperties +from ._models_py3 import GatewayCustomDomainProperties +from ._models_py3 import GatewayCustomDomainResource +from ._models_py3 import GatewayCustomDomainResourceCollection +from ._models_py3 import GatewayInstance +from ._models_py3 import GatewayOperatorProperties +from ._models_py3 import GatewayOperatorResourceRequests +from ._models_py3 import GatewayProperties +from ._models_py3 import GatewayResource +from ._models_py3 import GatewayResourceCollection +from ._models_py3 import GatewayResourceRequests +from ._models_py3 import GatewayRouteConfigOpenApiProperties +from ._models_py3 import GatewayRouteConfigProperties +from ._models_py3 import GatewayRouteConfigResource +from ._models_py3 import GatewayRouteConfigResourceCollection +from ._models_py3 import GitPatternRepository +from ._models_py3 import HTTPGetAction +from ._models_py3 import ImageRegistryCredential +from ._models_py3 import IngressConfig +from ._models_py3 import IngressSettings +from ._models_py3 import IngressSettingsClientAuth +from ._models_py3 import JarUploadedUserSourceInfo +from ._models_py3 import KeyVaultCertificateProperties +from ._models_py3 import LoadedCertificate +from ._models_py3 import LogFileUrlResponse +from ._models_py3 import LogSpecification +from ._models_py3 import ManagedIdentityProperties +from ._models_py3 import MarketplaceResource +from ._models_py3 import MetricDimension +from ._models_py3 import MetricSpecification +from ._models_py3 import MonitoringSettingProperties +from ._models_py3 import MonitoringSettingResource +from ._models_py3 import NameAvailability +from ._models_py3 import NameAvailabilityParameters +from ._models_py3 import NetCoreZipUploadedUserSourceInfo +from ._models_py3 import NetworkProfile +from ._models_py3 import NetworkProfileOutboundIPs +from ._models_py3 import OperationDetail +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationProperties +from ._models_py3 import PersistentDisk +from ._models_py3 import Probe +from ._models_py3 import ProbeAction +from ._models_py3 import ProxyResource +from ._models_py3 import RegenerateTestKeyRequestPayload +from ._models_py3 import RemoteDebugging +from ._models_py3 import RemoteDebuggingPayload +from ._models_py3 import RequiredTraffic +from ._models_py3 import Resource +from ._models_py3 import ResourceRequests +from ._models_py3 import ResourceSku +from ._models_py3 import ResourceSkuCapabilities +from ._models_py3 import ResourceSkuCollection +from ._models_py3 import ResourceSkuLocationInfo +from ._models_py3 import ResourceSkuRestrictionInfo +from ._models_py3 import ResourceSkuRestrictions +from ._models_py3 import ResourceSkuZoneDetails +from ._models_py3 import ResourceUploadDefinition +from ._models_py3 import ServiceRegistryInstance +from ._models_py3 import ServiceRegistryProperties +from ._models_py3 import ServiceRegistryResource +from ._models_py3 import ServiceRegistryResourceCollection +from ._models_py3 import ServiceRegistryResourceRequests +from ._models_py3 import ServiceResource +from ._models_py3 import ServiceResourceList +from ._models_py3 import ServiceSpecification +from ._models_py3 import ServiceVNetAddons +from ._models_py3 import Sku +from ._models_py3 import SkuCapacity +from ._models_py3 import SourceUploadedUserSourceInfo +from ._models_py3 import SsoProperties +from ._models_py3 import StackProperties +from ._models_py3 import StorageAccount +from ._models_py3 import StorageProperties +from ._models_py3 import StorageResource +from ._models_py3 import StorageResourceCollection +from ._models_py3 import SupportedBuildpackResource +from ._models_py3 import SupportedBuildpackResourceProperties +from ._models_py3 import SupportedBuildpacksCollection +from ._models_py3 import SupportedRuntimeVersion +from ._models_py3 import SupportedStackResource +from ._models_py3 import SupportedStackResourceProperties +from ._models_py3 import SupportedStacksCollection +from ._models_py3 import SystemData +from ._models_py3 import TCPSocketAction +from ._models_py3 import TemporaryDisk +from ._models_py3 import TestKeys +from ._models_py3 import TrackedResource +from ._models_py3 import TriggeredBuildResult +from ._models_py3 import UploadedUserSourceInfo +from ._models_py3 import UserAssignedManagedIdentity +from ._models_py3 import UserSourceInfo +from ._models_py3 import ValidationMessages + +from ._app_platform_management_client_enums import ActionType +from ._app_platform_management_client_enums import ApiPortalProvisioningState +from ._app_platform_management_client_enums import AppResourceProvisioningState +from ._app_platform_management_client_enums import BackendProtocol +from ._app_platform_management_client_enums import BindingType +from ._app_platform_management_client_enums import BuildProvisioningState +from ._app_platform_management_client_enums import BuildResultProvisioningState +from ._app_platform_management_client_enums import BuildServiceProvisioningState +from ._app_platform_management_client_enums import BuilderProvisioningState +from ._app_platform_management_client_enums import BuildpackBindingProvisioningState +from ._app_platform_management_client_enums import CertificateResourceProvisioningState +from ._app_platform_management_client_enums import ConfigServerState +from ._app_platform_management_client_enums import ConfigurationServiceProvisioningState +from ._app_platform_management_client_enums import CreatedByType +from ._app_platform_management_client_enums import CustomDomainResourceProvisioningState +from ._app_platform_management_client_enums import DeploymentResourceProvisioningState +from ._app_platform_management_client_enums import DeploymentResourceStatus +from ._app_platform_management_client_enums import GatewayProvisioningState +from ._app_platform_management_client_enums import GatewayRouteConfigProtocol +from ._app_platform_management_client_enums import HTTPSchemeType +from ._app_platform_management_client_enums import KPackBuildStageProvisioningState +from ._app_platform_management_client_enums import LastModifiedByType +from ._app_platform_management_client_enums import ManagedIdentityType +from ._app_platform_management_client_enums import MonitoringSettingState +from ._app_platform_management_client_enums import PowerState +from ._app_platform_management_client_enums import ProbeActionType +from ._app_platform_management_client_enums import ProvisioningState +from ._app_platform_management_client_enums import ResourceSkuRestrictionsReasonCode +from ._app_platform_management_client_enums import ResourceSkuRestrictionsType +from ._app_platform_management_client_enums import ServiceRegistryProvisioningState +from ._app_platform_management_client_enums import SessionAffinity +from ._app_platform_management_client_enums import SkuScaleType +from ._app_platform_management_client_enums import StorageType +from ._app_platform_management_client_enums import SupportedRuntimePlatform +from ._app_platform_management_client_enums import SupportedRuntimeValue +from ._app_platform_management_client_enums import TestKeyType +from ._app_platform_management_client_enums import TrafficDirection +from ._app_platform_management_client_enums import Type +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__ = [ + "ActiveDeploymentCollection", + "ApiPortalCustomDomainProperties", + "ApiPortalCustomDomainResource", + "ApiPortalCustomDomainResourceCollection", + "ApiPortalInstance", + "ApiPortalProperties", + "ApiPortalResource", + "ApiPortalResourceCollection", + "ApiPortalResourceRequests", + "AppResource", + "AppResourceCollection", + "AppResourceProperties", + "AppVNetAddons", + "ApplicationInsightsAgentVersions", + "AvailableOperations", + "AvailableRuntimeVersions", + "AzureFileVolume", + "BindingResource", + "BindingResourceCollection", + "BindingResourceProperties", + "Build", + "BuildCollection", + "BuildProperties", + "BuildResourceRequests", + "BuildResult", + "BuildResultCollection", + "BuildResultLog", + "BuildResultProperties", + "BuildResultUserSourceInfo", + "BuildService", + "BuildServiceAgentPoolProperties", + "BuildServiceAgentPoolResource", + "BuildServiceAgentPoolResourceCollection", + "BuildServiceAgentPoolSizeProperties", + "BuildServiceCollection", + "BuildServiceProperties", + "BuildServicePropertiesResourceRequests", + "BuildStageProperties", + "BuilderProperties", + "BuilderResource", + "BuilderResourceCollection", + "BuildpackBindingLaunchProperties", + "BuildpackBindingProperties", + "BuildpackBindingResource", + "BuildpackBindingResourceCollection", + "BuildpackProperties", + "BuildpacksGroupProperties", + "CertificateProperties", + "CertificateResource", + "CertificateResourceCollection", + "CloudErrorBody", + "ClusterResourceProperties", + "ConfigServerGitProperty", + "ConfigServerProperties", + "ConfigServerResource", + "ConfigServerSettings", + "ConfigServerSettingsErrorRecord", + "ConfigServerSettingsValidateResult", + "ConfigurationServiceGitProperty", + "ConfigurationServiceGitPropertyValidateResult", + "ConfigurationServiceGitRepository", + "ConfigurationServiceInstance", + "ConfigurationServiceProperties", + "ConfigurationServiceResource", + "ConfigurationServiceResourceCollection", + "ConfigurationServiceResourceRequests", + "ConfigurationServiceSettings", + "ConfigurationServiceSettingsValidateResult", + "ContainerProbeSettings", + "ContentCertificateProperties", + "CustomContainer", + "CustomContainerUserSourceInfo", + "CustomDomainProperties", + "CustomDomainResource", + "CustomDomainResourceCollection", + "CustomDomainValidatePayload", + "CustomDomainValidateResult", + "CustomPersistentDiskProperties", + "CustomPersistentDiskResource", + "DeploymentInstance", + "DeploymentList", + "DeploymentResource", + "DeploymentResourceCollection", + "DeploymentResourceProperties", + "DeploymentSettings", + "DiagnosticParameters", + "Error", + "ExecAction", + "GatewayApiMetadataProperties", + "GatewayApiRoute", + "GatewayCorsProperties", + "GatewayCustomDomainProperties", + "GatewayCustomDomainResource", + "GatewayCustomDomainResourceCollection", + "GatewayInstance", + "GatewayOperatorProperties", + "GatewayOperatorResourceRequests", + "GatewayProperties", + "GatewayResource", + "GatewayResourceCollection", + "GatewayResourceRequests", + "GatewayRouteConfigOpenApiProperties", + "GatewayRouteConfigProperties", + "GatewayRouteConfigResource", + "GatewayRouteConfigResourceCollection", + "GitPatternRepository", + "HTTPGetAction", + "ImageRegistryCredential", + "IngressConfig", + "IngressSettings", + "IngressSettingsClientAuth", + "JarUploadedUserSourceInfo", + "KeyVaultCertificateProperties", + "LoadedCertificate", + "LogFileUrlResponse", + "LogSpecification", + "ManagedIdentityProperties", + "MarketplaceResource", + "MetricDimension", + "MetricSpecification", + "MonitoringSettingProperties", + "MonitoringSettingResource", + "NameAvailability", + "NameAvailabilityParameters", + "NetCoreZipUploadedUserSourceInfo", + "NetworkProfile", + "NetworkProfileOutboundIPs", + "OperationDetail", + "OperationDisplay", + "OperationProperties", + "PersistentDisk", + "Probe", + "ProbeAction", + "ProxyResource", + "RegenerateTestKeyRequestPayload", + "RemoteDebugging", + "RemoteDebuggingPayload", + "RequiredTraffic", + "Resource", + "ResourceRequests", + "ResourceSku", + "ResourceSkuCapabilities", + "ResourceSkuCollection", + "ResourceSkuLocationInfo", + "ResourceSkuRestrictionInfo", + "ResourceSkuRestrictions", + "ResourceSkuZoneDetails", + "ResourceUploadDefinition", + "ServiceRegistryInstance", + "ServiceRegistryProperties", + "ServiceRegistryResource", + "ServiceRegistryResourceCollection", + "ServiceRegistryResourceRequests", + "ServiceResource", + "ServiceResourceList", + "ServiceSpecification", + "ServiceVNetAddons", + "Sku", + "SkuCapacity", + "SourceUploadedUserSourceInfo", + "SsoProperties", + "StackProperties", + "StorageAccount", + "StorageProperties", + "StorageResource", + "StorageResourceCollection", + "SupportedBuildpackResource", + "SupportedBuildpackResourceProperties", + "SupportedBuildpacksCollection", + "SupportedRuntimeVersion", + "SupportedStackResource", + "SupportedStackResourceProperties", + "SupportedStacksCollection", + "SystemData", + "TCPSocketAction", + "TemporaryDisk", + "TestKeys", + "TrackedResource", + "TriggeredBuildResult", + "UploadedUserSourceInfo", + "UserAssignedManagedIdentity", + "UserSourceInfo", + "ValidationMessages", + "ActionType", + "ApiPortalProvisioningState", + "AppResourceProvisioningState", + "BackendProtocol", + "BindingType", + "BuildProvisioningState", + "BuildResultProvisioningState", + "BuildServiceProvisioningState", + "BuilderProvisioningState", + "BuildpackBindingProvisioningState", + "CertificateResourceProvisioningState", + "ConfigServerState", + "ConfigurationServiceProvisioningState", + "CreatedByType", + "CustomDomainResourceProvisioningState", + "DeploymentResourceProvisioningState", + "DeploymentResourceStatus", + "GatewayProvisioningState", + "GatewayRouteConfigProtocol", + "HTTPSchemeType", + "KPackBuildStageProvisioningState", + "LastModifiedByType", + "ManagedIdentityType", + "MonitoringSettingState", + "PowerState", + "ProbeActionType", + "ProvisioningState", + "ResourceSkuRestrictionsReasonCode", + "ResourceSkuRestrictionsType", + "ServiceRegistryProvisioningState", + "SessionAffinity", + "SkuScaleType", + "StorageType", + "SupportedRuntimePlatform", + "SupportedRuntimeValue", + "TestKeyType", + "TrafficDirection", + "Type", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/models/_app_platform_management_client_enums.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/models/_app_platform_management_client_enums.py new file mode 100644 index 000000000000..c22d729c3880 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/models/_app_platform_management_client_enums.py @@ -0,0 +1,350 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" + + INTERNAL = "Internal" + + +class ApiPortalProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the API portal.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class AppResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the App.""" + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + + +class BackendProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """How ingress should communicate with this app backend service.""" + + GRPC = "GRPC" + DEFAULT = "Default" + + +class BindingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Buildpack Binding Type.""" + + APPLICATION_INSIGHTS = "ApplicationInsights" + APACHE_SKY_WALKING = "ApacheSkyWalking" + APP_DYNAMICS = "AppDynamics" + DYNATRACE = "Dynatrace" + NEW_RELIC = "NewRelic" + ELASTIC_APM = "ElasticAPM" + + +class BuilderProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Builder provision status.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class BuildpackBindingProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Buildpack Binding.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class BuildProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class BuildResultProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" + + QUEUING = "Queuing" + BUILDING = "Building" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class BuildServiceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class CertificateResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Certificate.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class ConfigServerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the config server.""" + + NOT_AVAILABLE = "NotAvailable" + DELETED = "Deleted" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + + +class ConfigurationServiceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Application Configuration Service.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class CustomDomainResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Domain.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class DeploymentResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Deployment.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + + +class DeploymentResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the Deployment.""" + + STOPPED = "Stopped" + RUNNING = "Running" + + +class GatewayProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Spring Cloud Gateway.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class GatewayRouteConfigProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Protocol of routed Azure Spring Apps applications.""" + + HTTP = "HTTP" + HTTPS = "HTTPS" + + +class HTTPSchemeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scheme to use for connecting to the host. Defaults to HTTP. + + Possible enum values: + + + * ``"HTTP"`` means that the scheme used will be http:// + * ``"HTTPS"`` means that the scheme used will be https://. + """ + + HTTP = "HTTP" + HTTPS = "HTTPS" + + +class KPackBuildStageProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of this build stage resource.""" + + NOT_STARTED = "NotStarted" + RUNNING = "Running" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the managed identity.""" + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + + +class MonitoringSettingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Monitoring Setting.""" + + NOT_AVAILABLE = "NotAvailable" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + + +class PowerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Power state of the Service.""" + + RUNNING = "Running" + STOPPED = "Stopped" + + +class ProbeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the action to take to perform the health check.""" + + HTTP_GET_ACTION = "HTTPGetAction" + TCP_SOCKET_ACTION = "TCPSocketAction" + EXEC_ACTION = "ExecAction" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Service.""" + + CREATING = "Creating" + UPDATING = "Updating" + STARTING = "Starting" + STOPPING = "Stopping" + DELETING = "Deleting" + DELETED = "Deleted" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + MOVING = "Moving" + MOVED = "Moved" + MOVE_FAILED = "MoveFailed" + + +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the reason for restriction. Possible values include: 'QuotaId', + 'NotAvailableForSubscription'. + """ + + QUOTA_ID = "QuotaId" + NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + + +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the type of restrictions. Possible values include: 'Location', 'Zone'.""" + + LOCATION = "Location" + ZONE = "Zone" + + +class ServiceRegistryProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Service Registry.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class SessionAffinity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the affinity, set this to Cookie to enable session affinity.""" + + COOKIE = "Cookie" + NONE = "None" + + +class SkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type of the scale.""" + + NONE = "None" + MANUAL = "Manual" + AUTOMATIC = "Automatic" + + +class StorageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the storage.""" + + STORAGE_ACCOUNT = "StorageAccount" + + +class SupportedRuntimePlatform(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The platform of this runtime version (possible values: "Java" or ".NET").""" + + JAVA = "Java" + _NET_CORE = ".NET Core" + + +class SupportedRuntimeValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The raw value which could be passed to deployment CRUD operations.""" + + JAVA8 = "Java_8" + JAVA11 = "Java_11" + JAVA17 = "Java_17" + NET_CORE31 = "NetCore_31" + + +class TestKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the test key.""" + + PRIMARY = "Primary" + SECONDARY = "Secondary" + + +class TrafficDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The direction of required traffic.""" + + INBOUND = "Inbound" + OUTBOUND = "Outbound" + + +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the underlying resource to mount as a persistent disk.""" + + AZURE_FILE_VOLUME = "AzureFileVolume" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/models/_models_py3.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/models/_models_py3.py new file mode 100644 index 000000000000..29ffde39942b --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/models/_models_py3.py @@ -0,0 +1,7754 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object + + +class ActiveDeploymentCollection(_serialization.Model): + """Object that includes an array of Deployment resource name and set them as active. + + :ivar active_deployment_names: Collection of Deployment name. + :vartype active_deployment_names: list[str] + """ + + _attribute_map = { + "active_deployment_names": {"key": "activeDeploymentNames", "type": "[str]"}, + } + + def __init__(self, *, active_deployment_names: Optional[List[str]] = None, **kwargs): + """ + :keyword active_deployment_names: Collection of Deployment name. + :paramtype active_deployment_names: list[str] + """ + super().__init__(**kwargs) + self.active_deployment_names = active_deployment_names + + +class ApiPortalCustomDomainProperties(_serialization.Model): + """The properties of custom domain for API portal. + + :ivar thumbprint: The thumbprint of bound certificate. + :vartype thumbprint: str + """ + + _attribute_map = { + "thumbprint": {"key": "thumbprint", "type": "str"}, + } + + def __init__(self, *, thumbprint: Optional[str] = None, **kwargs): + """ + :keyword thumbprint: The thumbprint of bound certificate. + :paramtype thumbprint: str + """ + super().__init__(**kwargs) + self.thumbprint = thumbprint + + +class Resource(_serialization.Model): + """The core properties of ARM resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class ProxyResource(Resource): + """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + + +class ApiPortalCustomDomainResource(ProxyResource): + """Custom domain of the API portal. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: The properties of custom domain for API portal. + :vartype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainProperties + """ + + _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": "ApiPortalCustomDomainProperties"}, + } + + def __init__(self, *, properties: Optional["_models.ApiPortalCustomDomainProperties"] = None, **kwargs): + """ + :keyword properties: The properties of custom domain for API portal. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ApiPortalCustomDomainResourceCollection(_serialization.Model): + """Object that includes an array of API portal custom domain resources and a possible link for next set. + + :ivar value: Collection of API portal custom domain resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ApiPortalCustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ApiPortalCustomDomainResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of API portal custom domain resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApiPortalInstance(_serialization.Model): + """Collection of instances belong to the API portal. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the API portal instance. + :vartype name: str + :ivar status: Status of the API portal instance. + :vartype status: str + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + + +class ApiPortalProperties(_serialization.Model): + """API portal properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the API portal. Known values are: "Creating", "Updating", + "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalProvisioningState + :ivar public: Indicates whether the API portal exposes endpoint. + :vartype public: bool + :ivar url: URL of the API portal, exposed when 'public' is true. + :vartype url: str + :ivar https_only: Indicate if only https is allowed. + :vartype https_only: bool + :ivar gateway_ids: The array of resource Ids of gateway to integrate with API portal. + :vartype gateway_ids: list[str] + :ivar source_urls: Collection of OpenAPI source URL locations. + :vartype source_urls: list[str] + :ivar sso_properties: Single sign-on related configuration. + :vartype sso_properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SsoProperties + :ivar resource_requests: The requested resource quantity for required CPU and Memory. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResourceRequests + :ivar instances: Collection of instances belong to API portal. + :vartype instances: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalInstance] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "url": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "gateway_ids": {"key": "gatewayIds", "type": "[str]"}, + "source_urls": {"key": "sourceUrls", "type": "[str]"}, + "sso_properties": {"key": "ssoProperties", "type": "SsoProperties"}, + "resource_requests": {"key": "resourceRequests", "type": "ApiPortalResourceRequests"}, + "instances": {"key": "instances", "type": "[ApiPortalInstance]"}, + } + + def __init__( + self, + *, + public: bool = False, + https_only: bool = False, + gateway_ids: Optional[List[str]] = None, + source_urls: Optional[List[str]] = None, + sso_properties: Optional["_models.SsoProperties"] = None, + **kwargs + ): + """ + :keyword public: Indicates whether the API portal exposes endpoint. + :paramtype public: bool + :keyword https_only: Indicate if only https is allowed. + :paramtype https_only: bool + :keyword gateway_ids: The array of resource Ids of gateway to integrate with API portal. + :paramtype gateway_ids: list[str] + :keyword source_urls: Collection of OpenAPI source URL locations. + :paramtype source_urls: list[str] + :keyword sso_properties: Single sign-on related configuration. + :paramtype sso_properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SsoProperties + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.public = public + self.url = None + self.https_only = https_only + self.gateway_ids = gateway_ids + self.source_urls = source_urls + self.sso_properties = sso_properties + self.resource_requests = None + self.instances = None + + +class ApiPortalResource(ProxyResource): + """API portal resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: API portal properties payload. + :vartype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalProperties + :ivar sku: Sku of the API portal resource. + :vartype sku: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Sku + """ + + _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": "ApiPortalProperties"}, + "sku": {"key": "sku", "type": "Sku"}, + } + + def __init__( + self, + *, + properties: Optional["_models.ApiPortalProperties"] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword properties: API portal properties payload. + :paramtype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalProperties + :keyword sku: Sku of the API portal resource. + :paramtype sku: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Sku + """ + super().__init__(**kwargs) + self.properties = properties + self.sku = sku + + +class ApiPortalResourceCollection(_serialization.Model): + """Object that includes an array of API portal resources and a possible link for next set. + + :ivar value: Collection of API portal resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ApiPortalResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.ApiPortalResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of API portal resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApiPortalResourceRequests(_serialization.Model): + """Resource requests of the API portal. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: Cpu allocated to each API portal instance. + :vartype cpu: str + :ivar memory: Memory allocated to each API portal instance. + :vartype memory: str + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + } + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.cpu = None + self.memory = None + + +class ApplicationInsightsAgentVersions(_serialization.Model): + """Application Insights agent versions properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar java: Indicates the version of application insight java agent. + :vartype java: str + """ + + _validation = { + "java": {"readonly": True}, + } + + _attribute_map = { + "java": {"key": "java", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.java = None + + +class AppResource(ProxyResource): + """App resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Properties of the App resource. + :vartype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResourceProperties + :ivar identity: The Managed Identity type of the app resource. + :vartype identity: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ManagedIdentityProperties + :ivar location: The GEO location of the application, always the same with its parent resource. + :vartype location: str + """ + + _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": "AppResourceProperties"}, + "identity": {"key": "identity", "type": "ManagedIdentityProperties"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__( + self, + *, + properties: Optional["_models.AppResourceProperties"] = None, + identity: Optional["_models.ManagedIdentityProperties"] = None, + location: Optional[str] = None, + **kwargs + ): + """ + :keyword properties: Properties of the App resource. + :paramtype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResourceProperties + :keyword identity: The Managed Identity type of the app resource. + :paramtype identity: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ManagedIdentityProperties + :keyword location: The GEO location of the application, always the same with its parent + resource. + :paramtype location: str + """ + super().__init__(**kwargs) + self.properties = properties + self.identity = identity + self.location = location + + +class AppResourceCollection(_serialization.Model): + """Object that includes an array of App resources and a possible link for next set. + + :ivar value: Collection of App resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AppResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.AppResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of App resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AppResourceProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """App resource properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar public: Indicates whether the App exposes public endpoint. + :vartype public: bool + :ivar url: URL of the App. + :vartype url: str + :ivar addon_configs: Collection of addons. + :vartype addon_configs: dict[str, dict[str, JSON]] + :ivar provisioning_state: Provisioning state of the App. Known values are: "Succeeded", + "Failed", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResourceProvisioningState + :ivar fqdn: Fully qualified dns Name. + :vartype fqdn: str + :ivar https_only: Indicate if only https is allowed. + :vartype https_only: bool + :ivar temporary_disk: Temporary disk settings. + :vartype temporary_disk: ~azure.mgmt.appplatform.v2022_09_01_preview.models.TemporaryDisk + :ivar persistent_disk: Persistent disk settings. + :vartype persistent_disk: ~azure.mgmt.appplatform.v2022_09_01_preview.models.PersistentDisk + :ivar custom_persistent_disks: List of custom persistent disks. + :vartype custom_persistent_disks: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomPersistentDiskResource] + :ivar enable_end_to_end_tls: Indicate if end to end TLS is enabled. + :vartype enable_end_to_end_tls: bool + :ivar loaded_certificates: Collection of loaded certificates. + :vartype loaded_certificates: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.LoadedCertificate] + :ivar vnet_addons: Additional App settings in vnet injection instance. + :vartype vnet_addons: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppVNetAddons + :ivar ingress_settings: App ingress settings payload. + :vartype ingress_settings: ~azure.mgmt.appplatform.v2022_09_01_preview.models.IngressSettings + """ + + _validation = { + "url": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "fqdn": {"readonly": True}, + } + + _attribute_map = { + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "addon_configs": {"key": "addonConfigs", "type": "{{object}}"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "fqdn": {"key": "fqdn", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "temporary_disk": {"key": "temporaryDisk", "type": "TemporaryDisk"}, + "persistent_disk": {"key": "persistentDisk", "type": "PersistentDisk"}, + "custom_persistent_disks": {"key": "customPersistentDisks", "type": "[CustomPersistentDiskResource]"}, + "enable_end_to_end_tls": {"key": "enableEndToEndTLS", "type": "bool"}, + "loaded_certificates": {"key": "loadedCertificates", "type": "[LoadedCertificate]"}, + "vnet_addons": {"key": "vnetAddons", "type": "AppVNetAddons"}, + "ingress_settings": {"key": "ingressSettings", "type": "IngressSettings"}, + } + + def __init__( + self, + *, + public: Optional[bool] = None, + addon_configs: Optional[Dict[str, Dict[str, JSON]]] = None, + https_only: bool = False, + temporary_disk: Optional["_models.TemporaryDisk"] = None, + persistent_disk: Optional["_models.PersistentDisk"] = None, + custom_persistent_disks: Optional[List["_models.CustomPersistentDiskResource"]] = None, + enable_end_to_end_tls: bool = False, + loaded_certificates: Optional[List["_models.LoadedCertificate"]] = None, + vnet_addons: Optional["_models.AppVNetAddons"] = None, + ingress_settings: Optional["_models.IngressSettings"] = None, + **kwargs + ): + """ + :keyword public: Indicates whether the App exposes public endpoint. + :paramtype public: bool + :keyword addon_configs: Collection of addons. + :paramtype addon_configs: dict[str, dict[str, JSON]] + :keyword https_only: Indicate if only https is allowed. + :paramtype https_only: bool + :keyword temporary_disk: Temporary disk settings. + :paramtype temporary_disk: ~azure.mgmt.appplatform.v2022_09_01_preview.models.TemporaryDisk + :keyword persistent_disk: Persistent disk settings. + :paramtype persistent_disk: ~azure.mgmt.appplatform.v2022_09_01_preview.models.PersistentDisk + :keyword custom_persistent_disks: List of custom persistent disks. + :paramtype custom_persistent_disks: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomPersistentDiskResource] + :keyword enable_end_to_end_tls: Indicate if end to end TLS is enabled. + :paramtype enable_end_to_end_tls: bool + :keyword loaded_certificates: Collection of loaded certificates. + :paramtype loaded_certificates: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.LoadedCertificate] + :keyword vnet_addons: Additional App settings in vnet injection instance. + :paramtype vnet_addons: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppVNetAddons + :keyword ingress_settings: App ingress settings payload. + :paramtype ingress_settings: ~azure.mgmt.appplatform.v2022_09_01_preview.models.IngressSettings + """ + super().__init__(**kwargs) + self.public = public + self.url = None + self.addon_configs = addon_configs + self.provisioning_state = None + self.fqdn = None + self.https_only = https_only + self.temporary_disk = temporary_disk + self.persistent_disk = persistent_disk + self.custom_persistent_disks = custom_persistent_disks + self.enable_end_to_end_tls = enable_end_to_end_tls + self.loaded_certificates = loaded_certificates + self.vnet_addons = vnet_addons + self.ingress_settings = ingress_settings + + +class AppVNetAddons(_serialization.Model): + """Additional App settings in vnet injection instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar public_endpoint: Indicates whether the App in vnet injection instance exposes endpoint + which could be accessed from internet. + :vartype public_endpoint: bool + :ivar public_endpoint_url: URL of the App in vnet injection instance which could be accessed + from internet. + :vartype public_endpoint_url: str + """ + + _validation = { + "public_endpoint_url": {"readonly": True}, + } + + _attribute_map = { + "public_endpoint": {"key": "publicEndpoint", "type": "bool"}, + "public_endpoint_url": {"key": "publicEndpointUrl", "type": "str"}, + } + + def __init__(self, *, public_endpoint: bool = False, **kwargs): + """ + :keyword public_endpoint: Indicates whether the App in vnet injection instance exposes endpoint + which could be accessed from internet. + :paramtype public_endpoint: bool + """ + super().__init__(**kwargs) + self.public_endpoint = public_endpoint + self.public_endpoint_url = None + + +class AvailableOperations(_serialization.Model): + """Available operations of the service. + + :ivar value: Collection of available operation details. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.OperationDetail] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[OperationDetail]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.OperationDetail"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of available operation details. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.OperationDetail] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AvailableRuntimeVersions(_serialization.Model): + """AvailableRuntimeVersions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of all supported runtime versions. + :vartype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedRuntimeVersion] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SupportedRuntimeVersion]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + + +class CustomPersistentDiskProperties(_serialization.Model): + """Custom persistent disk resource payload. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureFileVolume + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the underlying resource to mount as a persistent disk. Required. + "AzureFileVolume" + :vartype type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.Type + :ivar mount_path: The mount path of the persistent disk. Required. + :vartype mount_path: str + :ivar read_only: Indicates whether the persistent disk is a readOnly one. + :vartype read_only: bool + :ivar mount_options: These are the mount options for a persistent disk. + :vartype mount_options: list[str] + """ + + _validation = { + "type": {"required": True}, + "mount_path": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "mount_path": {"key": "mountPath", "type": "str"}, + "read_only": {"key": "readOnly", "type": "bool"}, + "mount_options": {"key": "mountOptions", "type": "[str]"}, + } + + _subtype_map = {"type": {"AzureFileVolume": "AzureFileVolume"}} + + def __init__( + self, *, mount_path: str, read_only: Optional[bool] = None, mount_options: Optional[List[str]] = None, **kwargs + ): + """ + :keyword mount_path: The mount path of the persistent disk. Required. + :paramtype mount_path: str + :keyword read_only: Indicates whether the persistent disk is a readOnly one. + :paramtype read_only: bool + :keyword mount_options: These are the mount options for a persistent disk. + :paramtype mount_options: list[str] + """ + super().__init__(**kwargs) + self.type = None # type: Optional[str] + self.mount_path = mount_path + self.read_only = read_only + self.mount_options = mount_options + + +class AzureFileVolume(CustomPersistentDiskProperties): + """The properties of the Azure File volume. Azure File shares are mounted as volumes. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the underlying resource to mount as a persistent disk. Required. + "AzureFileVolume" + :vartype type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.Type + :ivar mount_path: The mount path of the persistent disk. Required. + :vartype mount_path: str + :ivar read_only: Indicates whether the persistent disk is a readOnly one. + :vartype read_only: bool + :ivar mount_options: These are the mount options for a persistent disk. + :vartype mount_options: list[str] + :ivar share_name: The share name of the Azure File share. Required. + :vartype share_name: str + """ + + _validation = { + "type": {"required": True}, + "mount_path": {"required": True}, + "share_name": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "mount_path": {"key": "mountPath", "type": "str"}, + "read_only": {"key": "readOnly", "type": "bool"}, + "mount_options": {"key": "mountOptions", "type": "[str]"}, + "share_name": {"key": "shareName", "type": "str"}, + } + + def __init__( + self, + *, + mount_path: str, + share_name: str, + read_only: Optional[bool] = None, + mount_options: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword mount_path: The mount path of the persistent disk. Required. + :paramtype mount_path: str + :keyword read_only: Indicates whether the persistent disk is a readOnly one. + :paramtype read_only: bool + :keyword mount_options: These are the mount options for a persistent disk. + :paramtype mount_options: list[str] + :keyword share_name: The share name of the Azure File share. Required. + :paramtype share_name: str + """ + super().__init__(mount_path=mount_path, read_only=read_only, mount_options=mount_options, **kwargs) + self.type = "AzureFileVolume" # type: str + self.share_name = share_name + + +class BindingResource(ProxyResource): + """Binding resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Properties of the Binding resource. + :vartype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResourceProperties + """ + + _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": "BindingResourceProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BindingResourceProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the Binding resource. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResourceProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BindingResourceCollection(_serialization.Model): + """Object that includes an array of Binding resources and a possible link for next set. + + :ivar value: Collection of Binding resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[BindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.BindingResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of Binding resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BindingResourceProperties(_serialization.Model): + """Binding resource properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_name: The name of the bound resource. + :vartype resource_name: str + :ivar resource_type: The standard Azure resource type of the bound resource. + :vartype resource_type: str + :ivar resource_id: The Azure resource id of the bound resource. + :vartype resource_id: str + :ivar key: The key of the bound resource. + :vartype key: str + :ivar binding_parameters: Binding parameters of the Binding resource. + :vartype binding_parameters: dict[str, JSON] + :ivar generated_properties: The generated Spring Boot property file for this binding. The + secret will be deducted. + :vartype generated_properties: str + :ivar created_at: Creation time of the Binding resource. + :vartype created_at: str + :ivar updated_at: Update time of the Binding resource. + :vartype updated_at: str + """ + + _validation = { + "resource_name": {"readonly": True}, + "resource_type": {"readonly": True}, + "generated_properties": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + } + + _attribute_map = { + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "binding_parameters": {"key": "bindingParameters", "type": "{object}"}, + "generated_properties": {"key": "generatedProperties", "type": "str"}, + "created_at": {"key": "createdAt", "type": "str"}, + "updated_at": {"key": "updatedAt", "type": "str"}, + } + + def __init__( + self, + *, + resource_id: Optional[str] = None, + key: Optional[str] = None, + binding_parameters: Optional[Dict[str, JSON]] = None, + **kwargs + ): + """ + :keyword resource_id: The Azure resource id of the bound resource. + :paramtype resource_id: str + :keyword key: The key of the bound resource. + :paramtype key: str + :keyword binding_parameters: Binding parameters of the Binding resource. + :paramtype binding_parameters: dict[str, JSON] + """ + super().__init__(**kwargs) + self.resource_name = None + self.resource_type = None + self.resource_id = resource_id + self.key = key + self.binding_parameters = binding_parameters + self.generated_properties = None + self.created_at = None + self.updated_at = None + + +class Build(ProxyResource): + """Build resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Properties of the build resource. + :vartype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildProperties + """ + + _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": "BuildProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BuildProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the build resource. + :paramtype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BuildCollection(_serialization.Model): + """Object that includes an array of Build resources and a possible link for next set. + + :ivar value: Collection of Build resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.Build] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Build]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Build"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: Collection of Build resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.Build] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BuilderProperties(_serialization.Model): + """KPack Builder properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Builder provision status. Known values are: "Creating", "Updating", + "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderProvisioningState + :ivar stack: Builder cluster stack property. + :vartype stack: ~azure.mgmt.appplatform.v2022_09_01_preview.models.StackProperties + :ivar buildpack_groups: Builder buildpack groups. + :vartype buildpack_groups: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpacksGroupProperties] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "stack": {"key": "stack", "type": "StackProperties"}, + "buildpack_groups": {"key": "buildpackGroups", "type": "[BuildpacksGroupProperties]"}, + } + + def __init__( + self, + *, + stack: Optional["_models.StackProperties"] = None, + buildpack_groups: Optional[List["_models.BuildpacksGroupProperties"]] = None, + **kwargs + ): + """ + :keyword stack: Builder cluster stack property. + :paramtype stack: ~azure.mgmt.appplatform.v2022_09_01_preview.models.StackProperties + :keyword buildpack_groups: Builder buildpack groups. + :paramtype buildpack_groups: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpacksGroupProperties] + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.stack = stack + self.buildpack_groups = buildpack_groups + + +class BuilderResource(ProxyResource): + """KPack Builder resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Property of the Builder resource. + :vartype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderProperties + """ + + _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": "BuilderProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BuilderProperties"] = None, **kwargs): + """ + :keyword properties: Property of the Builder resource. + :paramtype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BuilderResourceCollection(_serialization.Model): + """Object that includes an array of Builder resources and a possible link for next set. + + :ivar value: Collection of Builder resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[BuilderResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.BuilderResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of Builder resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BuildpackBindingLaunchProperties(_serialization.Model): + """Buildpack Binding Launch Properties. + + :ivar properties: Non-sensitive properties for launchProperties. + :vartype properties: dict[str, str] + :ivar secrets: Sensitive properties for launchProperties. + :vartype secrets: dict[str, str] + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "{str}"}, + "secrets": {"key": "secrets", "type": "{str}"}, + } + + def __init__( + self, *, properties: Optional[Dict[str, str]] = None, secrets: Optional[Dict[str, str]] = None, **kwargs + ): + """ + :keyword properties: Non-sensitive properties for launchProperties. + :paramtype properties: dict[str, str] + :keyword secrets: Sensitive properties for launchProperties. + :paramtype secrets: dict[str, str] + """ + super().__init__(**kwargs) + self.properties = properties + self.secrets = secrets + + +class BuildpackBindingProperties(_serialization.Model): + """Properties of a buildpack binding. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar binding_type: Buildpack Binding Type. Known values are: "ApplicationInsights", + "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", and "ElasticAPM". + :vartype binding_type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingType + :ivar provisioning_state: State of the Buildpack Binding. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingProvisioningState + :ivar launch_properties: The object describes the buildpack binding launch properties. + :vartype launch_properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingLaunchProperties + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "binding_type": {"key": "bindingType", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "launch_properties": {"key": "launchProperties", "type": "BuildpackBindingLaunchProperties"}, + } + + def __init__( + self, + *, + binding_type: Optional[Union[str, "_models.BindingType"]] = None, + launch_properties: Optional["_models.BuildpackBindingLaunchProperties"] = None, + **kwargs + ): + """ + :keyword binding_type: Buildpack Binding Type. Known values are: "ApplicationInsights", + "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", and "ElasticAPM". + :paramtype binding_type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingType + :keyword launch_properties: The object describes the buildpack binding launch properties. + :paramtype launch_properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingLaunchProperties + """ + super().__init__(**kwargs) + self.binding_type = binding_type + self.provisioning_state = None + self.launch_properties = launch_properties + + +class BuildpackBindingResource(ProxyResource): + """Buildpack Binding Resource object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Properties of a buildpack binding. + :vartype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingProperties + """ + + _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": "BuildpackBindingProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BuildpackBindingProperties"] = None, **kwargs): + """ + :keyword properties: Properties of a buildpack binding. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BuildpackBindingResourceCollection(_serialization.Model): + """Object that includes an array of BuildpackBinding resources and a possible link for next set. + + :ivar value: Collection of BuildpackBinding resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[BuildpackBindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.BuildpackBindingResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of BuildpackBinding resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BuildpackProperties(_serialization.Model): + """Buildpack properties payload. + + :ivar id: Id of the buildpack. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: Id of the buildpack. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class BuildpacksGroupProperties(_serialization.Model): + """Buildpack group properties of the Builder. + + :ivar name: Buildpack group name. + :vartype name: str + :ivar buildpacks: Buildpacks in the buildpack group. + :vartype buildpacks: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackProperties] + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "buildpacks": {"key": "buildpacks", "type": "[BuildpackProperties]"}, + } + + def __init__( + self, *, name: Optional[str] = None, buildpacks: Optional[List["_models.BuildpackProperties"]] = None, **kwargs + ): + """ + :keyword name: Buildpack group name. + :paramtype name: str + :keyword buildpacks: Buildpacks in the buildpack group. + :paramtype buildpacks: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackProperties] + """ + super().__init__(**kwargs) + self.name = name + self.buildpacks = buildpacks + + +class BuildProperties(_serialization.Model): + """Build resource properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar relative_path: The relative path of source code. + :vartype relative_path: str + :ivar builder: The resource id of builder to build the source code. + :vartype builder: str + :ivar agent_pool: The resource id of agent pool. + :vartype agent_pool: str + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildProvisioningState + :ivar env: The environment variables for this build. + :vartype env: dict[str, str] + :ivar triggered_build_result: The build result triggered by this build. + :vartype triggered_build_result: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.TriggeredBuildResult + :ivar resource_requests: The customized build resource for this build. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildResourceRequests + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "triggered_build_result": {"readonly": True}, + } + + _attribute_map = { + "relative_path": {"key": "relativePath", "type": "str"}, + "builder": {"key": "builder", "type": "str"}, + "agent_pool": {"key": "agentPool", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "env": {"key": "env", "type": "{str}"}, + "triggered_build_result": {"key": "triggeredBuildResult", "type": "TriggeredBuildResult"}, + "resource_requests": {"key": "resourceRequests", "type": "BuildResourceRequests"}, + } + + def __init__( + self, + *, + relative_path: Optional[str] = None, + builder: Optional[str] = None, + agent_pool: Optional[str] = None, + env: Optional[Dict[str, str]] = None, + resource_requests: Optional["_models.BuildResourceRequests"] = None, + **kwargs + ): + """ + :keyword relative_path: The relative path of source code. + :paramtype relative_path: str + :keyword builder: The resource id of builder to build the source code. + :paramtype builder: str + :keyword agent_pool: The resource id of agent pool. + :paramtype agent_pool: str + :keyword env: The environment variables for this build. + :paramtype env: dict[str, str] + :keyword resource_requests: The customized build resource for this build. + :paramtype resource_requests: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildResourceRequests + """ + super().__init__(**kwargs) + self.relative_path = relative_path + self.builder = builder + self.agent_pool = agent_pool + self.provisioning_state = None + self.env = env + self.triggered_build_result = None + self.resource_requests = resource_requests + + +class BuildResourceRequests(_serialization.Model): + """Resource request payload of Build Resource. + + :ivar cpu: Optional Cpu allocated to the build resource. 1 core can be represented by 1 or + 1000m. + The default value is 1, this should not exceed build service agent pool cpu size. + :vartype cpu: str + :ivar memory: Optional Memory allocated to the build resource. 1 GB can be represented by 1Gi + or 1024Mi. + The default value is 2Gi, this should not exceed build service agent pool memory size. + :vartype memory: str + """ + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + } + + def __init__(self, *, cpu: str = "1", memory: str = "2Gi", **kwargs): + """ + :keyword cpu: Optional Cpu allocated to the build resource. 1 core can be represented by 1 or + 1000m. + The default value is 1, this should not exceed build service agent pool cpu size. + :paramtype cpu: str + :keyword memory: Optional Memory allocated to the build resource. 1 GB can be represented by + 1Gi or 1024Mi. + The default value is 2Gi, this should not exceed build service agent pool memory size. + :paramtype memory: str + """ + super().__init__(**kwargs) + self.cpu = cpu + self.memory = memory + + +class BuildResult(ProxyResource): + """Build result resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Properties of the build result resource. + :vartype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildResultProperties + """ + + _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": "BuildResultProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BuildResultProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the build result resource. + :paramtype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildResultProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BuildResultCollection(_serialization.Model): + """Object that includes an array of Build result resources and a possible link for next set. + + :ivar value: Collection of Build result resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildResult] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[BuildResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.BuildResult"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of Build result resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildResult] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BuildResultLog(_serialization.Model): + """Build result log resource properties payload. + + :ivar blob_url: The public download URL of this build result log. + :vartype blob_url: str + """ + + _attribute_map = { + "blob_url": {"key": "blobUrl", "type": "str"}, + } + + def __init__(self, *, blob_url: Optional[str] = None, **kwargs): + """ + :keyword blob_url: The public download URL of this build result log. + :paramtype blob_url: str + """ + super().__init__(**kwargs) + self.blob_url = blob_url + + +class BuildResultProperties(_serialization.Model): + """Build result resource properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of this build result. + :vartype name: str + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Queuing", "Building", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildResultProvisioningState + :ivar build_pod_name: The build pod name which can be used to get the build log streaming. + :vartype build_pod_name: str + :ivar build_stages: All of the build stage (init-container and container) resources in build + pod. + :vartype build_stages: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildStageProperties] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "build_stages": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "build_pod_name": {"key": "buildPodName", "type": "str"}, + "build_stages": {"key": "buildStages", "type": "[BuildStageProperties]"}, + } + + def __init__(self, *, name: Optional[str] = None, build_pod_name: Optional[str] = None, **kwargs): + """ + :keyword name: The name of this build result. + :paramtype name: str + :keyword build_pod_name: The build pod name which can be used to get the build log streaming. + :paramtype build_pod_name: str + """ + super().__init__(**kwargs) + self.name = name + self.provisioning_state = None + self.build_pod_name = build_pod_name + self.build_stages = None + + +class UserSourceInfo(_serialization.Model): + """Source information for a deployment. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + BuildResultUserSourceInfo, CustomContainerUserSourceInfo, UploadedUserSourceInfo + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the source uploaded. Required. + :vartype type: str + :ivar version: Version of the source. + :vartype version: str + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + _subtype_map = { + "type": { + "BuildResult": "BuildResultUserSourceInfo", + "Container": "CustomContainerUserSourceInfo", + "UploadedUserSourceInfo": "UploadedUserSourceInfo", + } + } + + def __init__(self, *, version: Optional[str] = None, **kwargs): + """ + :keyword version: Version of the source. + :paramtype version: str + """ + super().__init__(**kwargs) + self.type = None # type: Optional[str] + self.version = version + + +class BuildResultUserSourceInfo(UserSourceInfo): + """Reference to a build result. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the source uploaded. Required. + :vartype type: str + :ivar version: Version of the source. + :vartype version: str + :ivar build_result_id: Resource id of an existing succeeded build result under the same Spring + instance. + :vartype build_result_id: str + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "build_result_id": {"key": "buildResultId", "type": "str"}, + } + + def __init__(self, *, version: Optional[str] = None, build_result_id: Optional[str] = None, **kwargs): + """ + :keyword version: Version of the source. + :paramtype version: str + :keyword build_result_id: Resource id of an existing succeeded build result under the same + Spring instance. + :paramtype build_result_id: str + """ + super().__init__(version=version, **kwargs) + self.type = "BuildResult" # type: str + self.build_result_id = build_result_id + + +class BuildService(ProxyResource): + """Build service resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Properties of the build resource. + :vartype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceProperties + """ + + _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": "BuildServiceProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BuildServiceProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the build resource. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BuildServiceAgentPoolProperties(_serialization.Model): + """Build service agent pool properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Provisioning state of the build service agent pool. + :vartype provisioning_state: str + :ivar pool_size: build service agent pool size properties. + :vartype pool_size: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolSizeProperties + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "pool_size": {"key": "poolSize", "type": "BuildServiceAgentPoolSizeProperties"}, + } + + def __init__(self, *, pool_size: Optional["_models.BuildServiceAgentPoolSizeProperties"] = None, **kwargs): + """ + :keyword pool_size: build service agent pool size properties. + :paramtype pool_size: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolSizeProperties + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.pool_size = pool_size + + +class BuildServiceAgentPoolResource(ProxyResource): + """The build service agent pool resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: build service agent pool properties. + :vartype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolProperties + """ + + _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": "BuildServiceAgentPoolProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BuildServiceAgentPoolProperties"] = None, **kwargs): + """ + :keyword properties: build service agent pool properties. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BuildServiceAgentPoolResourceCollection(_serialization.Model): + """Object that includes an array of build service agent pool resources and a possible link for next set. + + :ivar value: Collection of build service agent pool resource. + :vartype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[BuildServiceAgentPoolResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.BuildServiceAgentPoolResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of build service agent pool resource. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BuildServiceAgentPoolSizeProperties(_serialization.Model): + """Build service agent pool size properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of build service agent pool size. + :vartype name: str + :ivar cpu: The cpu property of build service agent pool size. + :vartype cpu: str + :ivar memory: The memory property of build service agent pool size. + :vartype memory: str + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, **kwargs): + """ + :keyword name: The name of build service agent pool size. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + self.cpu = None + self.memory = None + + +class BuildServiceCollection(_serialization.Model): + """Object that includes an array of Build service resources and a possible link for next set. + + :ivar value: Collection of Build service resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildService] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[BuildService]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.BuildService"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of Build service resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildService] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BuildServiceProperties(_serialization.Model): + """Build service resource properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar k_pack_version: The installed KPack version in this build service. + :vartype k_pack_version: str + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceProvisioningState + :ivar resource_requests: The runtime resource configuration of this build service. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServicePropertiesResourceRequests + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "k_pack_version": {"key": "kPackVersion", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "BuildServicePropertiesResourceRequests"}, + } + + def __init__( + self, + *, + k_pack_version: Optional[str] = None, + resource_requests: Optional["_models.BuildServicePropertiesResourceRequests"] = None, + **kwargs + ): + """ + :keyword k_pack_version: The installed KPack version in this build service. + :paramtype k_pack_version: str + :keyword resource_requests: The runtime resource configuration of this build service. + :paramtype resource_requests: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServicePropertiesResourceRequests + """ + super().__init__(**kwargs) + self.k_pack_version = k_pack_version + self.provisioning_state = None + self.resource_requests = resource_requests + + +class BuildServicePropertiesResourceRequests(_serialization.Model): + """The runtime resource configuration of this build service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: vCPU allocated to the entire build service node pool. + :vartype cpu: str + :ivar memory: Memory allocated to the entire build service node pool. + :vartype memory: str + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + } + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.cpu = None + self.memory = None + + +class BuildStageProperties(_serialization.Model): + """The build stage (init-container and container) resources in build pod. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of this build stage resource. + :vartype name: str + :ivar status: The provisioning state of this build stage resource. Known values are: + "NotStarted", "Running", "Succeeded", and "Failed". + :vartype status: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.KPackBuildStageProvisioningState + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + + +class CertificateProperties(_serialization.Model): + """Certificate resource payload. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContentCertificateProperties, KeyVaultCertificateProperties + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the certificate source. Required. + :vartype type: str + :ivar thumbprint: The thumbprint of certificate. + :vartype thumbprint: str + :ivar issuer: The issuer of certificate. + :vartype issuer: str + :ivar issued_date: The issue date of certificate. + :vartype issued_date: str + :ivar expiration_date: The expiration date of certificate. + :vartype expiration_date: str + :ivar activate_date: The activate date of certificate. + :vartype activate_date: str + :ivar subject_name: The subject name of certificate. + :vartype subject_name: str + :ivar dns_names: The domain list of certificate. + :vartype dns_names: list[str] + :ivar provisioning_state: Provisioning state of the Certificate. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResourceProvisioningState + """ + + _validation = { + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + } + + _subtype_map = { + "type": { + "ContentCertificate": "ContentCertificateProperties", + "KeyVaultCertificate": "KeyVaultCertificateProperties", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type = None # type: Optional[str] + self.thumbprint = None + self.issuer = None + self.issued_date = None + self.expiration_date = None + self.activate_date = None + self.subject_name = None + self.dns_names = None + self.provisioning_state = None + + +class CertificateResource(ProxyResource): + """Certificate resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Properties of the certificate resource payload. + :vartype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateProperties + """ + + _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": "CertificateProperties"}, + } + + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the certificate resource payload. + :paramtype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class CertificateResourceCollection(_serialization.Model): + """Collection compose of certificate resources list and a possible link for next page. + + :ivar value: The certificate resources list. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource] + :ivar next_link: The link to next page of certificate list. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[CertificateResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.CertificateResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The certificate resources list. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource] + :keyword next_link: The link to next page of certificate list. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CloudErrorBody(_serialization.Model): + """An error response from the service. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in + error. + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.CloudErrorBody] + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, + **kwargs + ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.CloudErrorBody] + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class ClusterResourceProperties(_serialization.Model): + """Service properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Provisioning state of the Service. Known values are: "Creating", + "Updating", "Starting", "Stopping", "Deleting", "Deleted", "Succeeded", "Failed", "Moving", + "Moved", and "MoveFailed". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ProvisioningState + :ivar network_profile: Network profile of the Service. + :vartype network_profile: ~azure.mgmt.appplatform.v2022_09_01_preview.models.NetworkProfile + :ivar vnet_addons: Additional Service settings in vnet injection instance. + :vartype vnet_addons: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceVNetAddons + :ivar version: Version of the Service. + :vartype version: int + :ivar service_id: ServiceInstanceEntity GUID which uniquely identifies a created resource. + :vartype service_id: str + :ivar power_state: Power state of the Service. Known values are: "Running" and "Stopped". + :vartype power_state: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.PowerState + :ivar zone_redundant: + :vartype zone_redundant: bool + :ivar fqdn: Fully qualified dns name of the service instance. + :vartype fqdn: str + :ivar marketplace_resource: Purchasing 3rd party product of the Service resource. + :vartype marketplace_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.MarketplaceResource + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "service_id": {"readonly": True}, + "power_state": {"readonly": True}, + "fqdn": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "network_profile": {"key": "networkProfile", "type": "NetworkProfile"}, + "vnet_addons": {"key": "vnetAddons", "type": "ServiceVNetAddons"}, + "version": {"key": "version", "type": "int"}, + "service_id": {"key": "serviceId", "type": "str"}, + "power_state": {"key": "powerState", "type": "str"}, + "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, + "fqdn": {"key": "fqdn", "type": "str"}, + "marketplace_resource": {"key": "marketplaceResource", "type": "MarketplaceResource"}, + } + + def __init__( + self, + *, + network_profile: Optional["_models.NetworkProfile"] = None, + vnet_addons: Optional["_models.ServiceVNetAddons"] = None, + zone_redundant: bool = False, + marketplace_resource: Optional["_models.MarketplaceResource"] = None, + **kwargs + ): + """ + :keyword network_profile: Network profile of the Service. + :paramtype network_profile: ~azure.mgmt.appplatform.v2022_09_01_preview.models.NetworkProfile + :keyword vnet_addons: Additional Service settings in vnet injection instance. + :paramtype vnet_addons: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceVNetAddons + :keyword zone_redundant: + :paramtype zone_redundant: bool + :keyword marketplace_resource: Purchasing 3rd party product of the Service resource. + :paramtype marketplace_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.MarketplaceResource + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.network_profile = network_profile + self.vnet_addons = vnet_addons + self.version = None + self.service_id = None + self.power_state = None + self.zone_redundant = zone_redundant + self.fqdn = None + self.marketplace_resource = marketplace_resource + + +class ConfigServerGitProperty(_serialization.Model): + """Property of git. + + All required parameters must be populated in order to send to Azure. + + :ivar repositories: Repositories of git. + :vartype repositories: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.GitPatternRepository] + :ivar uri: URI of the repository. Required. + :vartype uri: str + :ivar label: Label of the repository. + :vartype label: str + :ivar search_paths: Searching path of the repository. + :vartype search_paths: list[str] + :ivar username: Username of git repository basic auth. + :vartype username: str + :ivar password: Password of git repository basic auth. + :vartype password: str + :ivar host_key: Public sshKey of git repository. + :vartype host_key: str + :ivar host_key_algorithm: SshKey algorithm of git repository. + :vartype host_key_algorithm: str + :ivar private_key: Private sshKey algorithm of git repository. + :vartype private_key: str + :ivar strict_host_key_checking: Strict host key checking or not. + :vartype strict_host_key_checking: bool + """ + + _validation = { + "uri": {"required": True}, + } + + _attribute_map = { + "repositories": {"key": "repositories", "type": "[GitPatternRepository]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, + } + + def __init__( + self, + *, + uri: str, + repositories: Optional[List["_models.GitPatternRepository"]] = None, + label: Optional[str] = None, + search_paths: Optional[List[str]] = None, + username: Optional[str] = None, + password: Optional[str] = None, + host_key: Optional[str] = None, + host_key_algorithm: Optional[str] = None, + private_key: Optional[str] = None, + strict_host_key_checking: Optional[bool] = None, + **kwargs + ): + """ + :keyword repositories: Repositories of git. + :paramtype repositories: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.GitPatternRepository] + :keyword uri: URI of the repository. Required. + :paramtype uri: str + :keyword label: Label of the repository. + :paramtype label: str + :keyword search_paths: Searching path of the repository. + :paramtype search_paths: list[str] + :keyword username: Username of git repository basic auth. + :paramtype username: str + :keyword password: Password of git repository basic auth. + :paramtype password: str + :keyword host_key: Public sshKey of git repository. + :paramtype host_key: str + :keyword host_key_algorithm: SshKey algorithm of git repository. + :paramtype host_key_algorithm: str + :keyword private_key: Private sshKey algorithm of git repository. + :paramtype private_key: str + :keyword strict_host_key_checking: Strict host key checking or not. + :paramtype strict_host_key_checking: bool + """ + super().__init__(**kwargs) + self.repositories = repositories + self.uri = uri + self.label = label + self.search_paths = search_paths + self.username = username + self.password = password + self.host_key = host_key + self.host_key_algorithm = host_key_algorithm + self.private_key = private_key + self.strict_host_key_checking = strict_host_key_checking + + +class ConfigServerProperties(_serialization.Model): + """Config server git properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the config server. Known values are: "NotAvailable", + "Deleted", "Failed", "Succeeded", and "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerState + :ivar error: Error when apply config server settings. + :vartype error: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Error + :ivar config_server: Settings of config server. + :vartype config_server: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerSettings + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "config_server": {"key": "configServer", "type": "ConfigServerSettings"}, + } + + def __init__( + self, + *, + error: Optional["_models.Error"] = None, + config_server: Optional["_models.ConfigServerSettings"] = None, + **kwargs + ): + """ + :keyword error: Error when apply config server settings. + :paramtype error: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Error + :keyword config_server: Settings of config server. + :paramtype config_server: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerSettings + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.error = error + self.config_server = config_server + + +class ConfigServerResource(ProxyResource): + """Config Server resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Properties of the Config Server resource. + :vartype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerProperties + """ + + _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": "ConfigServerProperties"}, + } + + def __init__(self, *, properties: Optional["_models.ConfigServerProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the Config Server resource. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ConfigServerSettings(_serialization.Model): + """The settings of config server. + + :ivar git_property: Property of git environment. + :vartype git_property: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerGitProperty + """ + + _attribute_map = { + "git_property": {"key": "gitProperty", "type": "ConfigServerGitProperty"}, + } + + def __init__(self, *, git_property: Optional["_models.ConfigServerGitProperty"] = None, **kwargs): + """ + :keyword git_property: Property of git environment. + :paramtype git_property: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerGitProperty + """ + super().__init__(**kwargs) + self.git_property = git_property + + +class ConfigServerSettingsErrorRecord(_serialization.Model): + """Error record of the config server settings. + + :ivar name: The name of the config server settings error record. + :vartype name: str + :ivar uri: The uri of the config server settings error record. + :vartype uri: str + :ivar messages: The detail error messages of the record. + :vartype messages: list[str] + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, + } + + def __init__( + self, *, name: Optional[str] = None, uri: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs + ): + """ + :keyword name: The name of the config server settings error record. + :paramtype name: str + :keyword uri: The uri of the config server settings error record. + :paramtype uri: str + :keyword messages: The detail error messages of the record. + :paramtype messages: list[str] + """ + super().__init__(**kwargs) + self.name = name + self.uri = uri + self.messages = messages + + +class ConfigServerSettingsValidateResult(_serialization.Model): + """Validation result for config server settings. + + :ivar is_valid: Indicate if the config server settings are valid. + :vartype is_valid: bool + :ivar details: The detail validation results. + :vartype details: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerSettingsErrorRecord] + """ + + _attribute_map = { + "is_valid": {"key": "isValid", "type": "bool"}, + "details": {"key": "details", "type": "[ConfigServerSettingsErrorRecord]"}, + } + + def __init__( + self, + *, + is_valid: Optional[bool] = None, + details: Optional[List["_models.ConfigServerSettingsErrorRecord"]] = None, + **kwargs + ): + """ + :keyword is_valid: Indicate if the config server settings are valid. + :paramtype is_valid: bool + :keyword details: The detail validation results. + :paramtype details: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerSettingsErrorRecord] + """ + super().__init__(**kwargs) + self.is_valid = is_valid + self.details = details + + +class ConfigurationServiceGitProperty(_serialization.Model): + """Property of git environment. + + :ivar repositories: Repositories of Application Configuration Service git property. + :vartype repositories: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceGitRepository] + """ + + _attribute_map = { + "repositories": {"key": "repositories", "type": "[ConfigurationServiceGitRepository]"}, + } + + def __init__(self, *, repositories: Optional[List["_models.ConfigurationServiceGitRepository"]] = None, **kwargs): + """ + :keyword repositories: Repositories of Application Configuration Service git property. + :paramtype repositories: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceGitRepository] + """ + super().__init__(**kwargs) + self.repositories = repositories + + +class ConfigurationServiceGitPropertyValidateResult(_serialization.Model): + """Validation result for configuration service settings. + + :ivar is_valid: Indicate if the configuration service settings are valid. + :vartype is_valid: bool + :ivar git_repos_validation_result: The detail validation results. + :vartype git_repos_validation_result: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ValidationMessages] + """ + + _attribute_map = { + "is_valid": {"key": "isValid", "type": "bool"}, + "git_repos_validation_result": {"key": "gitReposValidationResult", "type": "[ValidationMessages]"}, + } + + def __init__( + self, + *, + is_valid: Optional[bool] = None, + git_repos_validation_result: Optional[List["_models.ValidationMessages"]] = None, + **kwargs + ): + """ + :keyword is_valid: Indicate if the configuration service settings are valid. + :paramtype is_valid: bool + :keyword git_repos_validation_result: The detail validation results. + :paramtype git_repos_validation_result: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ValidationMessages] + """ + super().__init__(**kwargs) + self.is_valid = is_valid + self.git_repos_validation_result = git_repos_validation_result + + +class ConfigurationServiceGitRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Git repository property payload for Application Configuration Service. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name of the repository. Required. + :vartype name: str + :ivar patterns: Collection of patterns of the repository. Required. + :vartype patterns: list[str] + :ivar uri: URI of the repository. Required. + :vartype uri: str + :ivar label: Label of the repository. Required. + :vartype label: str + :ivar search_paths: Searching path of the repository. + :vartype search_paths: list[str] + :ivar username: Username of git repository basic auth. + :vartype username: str + :ivar password: Password of git repository basic auth. + :vartype password: str + :ivar host_key: Public sshKey of git repository. + :vartype host_key: str + :ivar host_key_algorithm: SshKey algorithm of git repository. + :vartype host_key_algorithm: str + :ivar private_key: Private sshKey algorithm of git repository. + :vartype private_key: str + :ivar strict_host_key_checking: Strict host key checking or not. + :vartype strict_host_key_checking: bool + """ + + _validation = { + "name": {"required": True}, + "patterns": {"required": True}, + "uri": {"required": True}, + "label": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "patterns": {"key": "patterns", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, + } + + def __init__( + self, + *, + name: str, + patterns: List[str], + uri: str, + label: str, + search_paths: Optional[List[str]] = None, + username: Optional[str] = None, + password: Optional[str] = None, + host_key: Optional[str] = None, + host_key_algorithm: Optional[str] = None, + private_key: Optional[str] = None, + strict_host_key_checking: Optional[bool] = None, + **kwargs + ): + """ + :keyword name: Name of the repository. Required. + :paramtype name: str + :keyword patterns: Collection of patterns of the repository. Required. + :paramtype patterns: list[str] + :keyword uri: URI of the repository. Required. + :paramtype uri: str + :keyword label: Label of the repository. Required. + :paramtype label: str + :keyword search_paths: Searching path of the repository. + :paramtype search_paths: list[str] + :keyword username: Username of git repository basic auth. + :paramtype username: str + :keyword password: Password of git repository basic auth. + :paramtype password: str + :keyword host_key: Public sshKey of git repository. + :paramtype host_key: str + :keyword host_key_algorithm: SshKey algorithm of git repository. + :paramtype host_key_algorithm: str + :keyword private_key: Private sshKey algorithm of git repository. + :paramtype private_key: str + :keyword strict_host_key_checking: Strict host key checking or not. + :paramtype strict_host_key_checking: bool + """ + super().__init__(**kwargs) + self.name = name + self.patterns = patterns + self.uri = uri + self.label = label + self.search_paths = search_paths + self.username = username + self.password = password + self.host_key = host_key + self.host_key_algorithm = host_key_algorithm + self.private_key = private_key + self.strict_host_key_checking = strict_host_key_checking + + +class ConfigurationServiceInstance(_serialization.Model): + """Collection of instances belong to the Application Configuration Service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Application Configuration Service instance. + :vartype name: str + :ivar status: Status of the Application Configuration Service instance. + :vartype status: str + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + + +class ConfigurationServiceProperties(_serialization.Model): + """Application Configuration Service properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the Application Configuration Service. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceProvisioningState + :ivar resource_requests: The requested resource quantity for required CPU and Memory. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResourceRequests + :ivar instances: Collection of instances belong to Application Configuration Service. + :vartype instances: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceInstance] + :ivar settings: The settings of Application Configuration Service. + :vartype settings: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceSettings + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "ConfigurationServiceResourceRequests"}, + "instances": {"key": "instances", "type": "[ConfigurationServiceInstance]"}, + "settings": {"key": "settings", "type": "ConfigurationServiceSettings"}, + } + + def __init__(self, *, settings: Optional["_models.ConfigurationServiceSettings"] = None, **kwargs): + """ + :keyword settings: The settings of Application Configuration Service. + :paramtype settings: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceSettings + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.resource_requests = None + self.instances = None + self.settings = settings + + +class ConfigurationServiceResource(ProxyResource): + """Application Configuration Service resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Application Configuration Service properties payload. + :vartype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceProperties + """ + + _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": "ConfigurationServiceProperties"}, + } + + def __init__(self, *, properties: Optional["_models.ConfigurationServiceProperties"] = None, **kwargs): + """ + :keyword properties: Application Configuration Service properties payload. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ConfigurationServiceResourceCollection(_serialization.Model): + """Object that includes an array of configuration service resources and a possible link for next set. + + :ivar value: Collection of configuration service resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ConfigurationServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ConfigurationServiceResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of configuration service resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ConfigurationServiceResourceRequests(_serialization.Model): + """Resource request payload of Application Configuration Service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: Cpu allocated to each Application Configuration Service instance. + :vartype cpu: str + :ivar memory: Memory allocated to each Application Configuration Service instance. + :vartype memory: str + :ivar instance_count: Instance count of the Application Configuration Service. + :vartype instance_count: int + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, + } + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.cpu = None + self.memory = None + self.instance_count = None + + +class ConfigurationServiceSettings(_serialization.Model): + """The settings of Application Configuration Service. + + :ivar git_property: Property of git environment. + :vartype git_property: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceGitProperty + """ + + _attribute_map = { + "git_property": {"key": "gitProperty", "type": "ConfigurationServiceGitProperty"}, + } + + def __init__(self, *, git_property: Optional["_models.ConfigurationServiceGitProperty"] = None, **kwargs): + """ + :keyword git_property: Property of git environment. + :paramtype git_property: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceGitProperty + """ + super().__init__(**kwargs) + self.git_property = git_property + + +class ConfigurationServiceSettingsValidateResult(_serialization.Model): + """Validation result for configuration service settings. + + :ivar git_property_validation_result: Validation result for configuration service settings. + :vartype git_property_validation_result: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceGitPropertyValidateResult + """ + + _attribute_map = { + "git_property_validation_result": { + "key": "gitPropertyValidationResult", + "type": "ConfigurationServiceGitPropertyValidateResult", + }, + } + + def __init__( + self, + *, + git_property_validation_result: Optional["_models.ConfigurationServiceGitPropertyValidateResult"] = None, + **kwargs + ): + """ + :keyword git_property_validation_result: Validation result for configuration service settings. + :paramtype git_property_validation_result: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceGitPropertyValidateResult + """ + super().__init__(**kwargs) + self.git_property_validation_result = git_property_validation_result + + +class ContainerProbeSettings(_serialization.Model): + """Container liveness and readiness probe settings. + + :ivar disable_probe: Indicates whether disable the liveness and readiness probe. + :vartype disable_probe: bool + """ + + _attribute_map = { + "disable_probe": {"key": "disableProbe", "type": "bool"}, + } + + def __init__(self, *, disable_probe: Optional[bool] = None, **kwargs): + """ + :keyword disable_probe: Indicates whether disable the liveness and readiness probe. + :paramtype disable_probe: bool + """ + super().__init__(**kwargs) + self.disable_probe = disable_probe + + +class ContentCertificateProperties(CertificateProperties): + """Properties of certificate imported from key vault. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the certificate source. Required. + :vartype type: str + :ivar thumbprint: The thumbprint of certificate. + :vartype thumbprint: str + :ivar issuer: The issuer of certificate. + :vartype issuer: str + :ivar issued_date: The issue date of certificate. + :vartype issued_date: str + :ivar expiration_date: The expiration date of certificate. + :vartype expiration_date: str + :ivar activate_date: The activate date of certificate. + :vartype activate_date: str + :ivar subject_name: The subject name of certificate. + :vartype subject_name: str + :ivar dns_names: The domain list of certificate. + :vartype dns_names: list[str] + :ivar provisioning_state: Provisioning state of the Certificate. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResourceProvisioningState + :ivar content: The content of uploaded certificate. + :vartype content: str + """ + + _validation = { + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "content": {"key": "content", "type": "str"}, + } + + def __init__(self, *, content: Optional[str] = None, **kwargs): + """ + :keyword content: The content of uploaded certificate. + :paramtype content: str + """ + super().__init__(**kwargs) + self.type = "ContentCertificate" # type: str + self.content = content + + +class CustomContainer(_serialization.Model): + """Custom container payload. + + :ivar server: The name of the registry that contains the container image. + :vartype server: str + :ivar container_image: Container image of the custom container. This should be in the form of + :code:``::code:`` without the server name of the registry. + :vartype container_image: str + :ivar command: Entrypoint array. Not executed within a shell. The docker image's ENTRYPOINT is + used if this is not provided. + :vartype command: list[str] + :ivar args: Arguments to the entrypoint. The docker image's CMD is used if this is not + provided. + :vartype args: list[str] + :ivar image_registry_credential: Credential of the image registry. + :vartype image_registry_credential: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ImageRegistryCredential + :ivar language_framework: Language framework of the container image uploaded. + :vartype language_framework: str + """ + + _attribute_map = { + "server": {"key": "server", "type": "str"}, + "container_image": {"key": "containerImage", "type": "str"}, + "command": {"key": "command", "type": "[str]"}, + "args": {"key": "args", "type": "[str]"}, + "image_registry_credential": {"key": "imageRegistryCredential", "type": "ImageRegistryCredential"}, + "language_framework": {"key": "languageFramework", "type": "str"}, + } + + def __init__( + self, + *, + server: Optional[str] = None, + container_image: Optional[str] = None, + command: Optional[List[str]] = None, + args: Optional[List[str]] = None, + image_registry_credential: Optional["_models.ImageRegistryCredential"] = None, + language_framework: Optional[str] = None, + **kwargs + ): + """ + :keyword server: The name of the registry that contains the container image. + :paramtype server: str + :keyword container_image: Container image of the custom container. This should be in the form + of :code:``::code:`` without the server name of the registry. + :paramtype container_image: str + :keyword command: Entrypoint array. Not executed within a shell. The docker image's ENTRYPOINT + is used if this is not provided. + :paramtype command: list[str] + :keyword args: Arguments to the entrypoint. The docker image's CMD is used if this is not + provided. + :paramtype args: list[str] + :keyword image_registry_credential: Credential of the image registry. + :paramtype image_registry_credential: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ImageRegistryCredential + :keyword language_framework: Language framework of the container image uploaded. + :paramtype language_framework: str + """ + super().__init__(**kwargs) + self.server = server + self.container_image = container_image + self.command = command + self.args = args + self.image_registry_credential = image_registry_credential + self.language_framework = language_framework + + +class CustomContainerUserSourceInfo(UserSourceInfo): + """Custom container user source info. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the source uploaded. Required. + :vartype type: str + :ivar version: Version of the source. + :vartype version: str + :ivar custom_container: Custom container payload. + :vartype custom_container: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomContainer + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "custom_container": {"key": "customContainer", "type": "CustomContainer"}, + } + + def __init__( + self, *, version: Optional[str] = None, custom_container: Optional["_models.CustomContainer"] = None, **kwargs + ): + """ + :keyword version: Version of the source. + :paramtype version: str + :keyword custom_container: Custom container payload. + :paramtype custom_container: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomContainer + """ + super().__init__(version=version, **kwargs) + self.type = "Container" # type: str + self.custom_container = custom_container + + +class CustomDomainProperties(_serialization.Model): + """Custom domain of app resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar thumbprint: The thumbprint of bound certificate. + :vartype thumbprint: str + :ivar app_name: The app name of domain. + :vartype app_name: str + :ivar cert_name: The bound certificate name of domain. + :vartype cert_name: str + :ivar provisioning_state: Provisioning state of the Domain. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResourceProvisioningState + """ + + _validation = { + "app_name": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "thumbprint": {"key": "thumbprint", "type": "str"}, + "app_name": {"key": "appName", "type": "str"}, + "cert_name": {"key": "certName", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + } + + def __init__(self, *, thumbprint: Optional[str] = None, cert_name: Optional[str] = None, **kwargs): + """ + :keyword thumbprint: The thumbprint of bound certificate. + :paramtype thumbprint: str + :keyword cert_name: The bound certificate name of domain. + :paramtype cert_name: str + """ + super().__init__(**kwargs) + self.thumbprint = thumbprint + self.app_name = None + self.cert_name = cert_name + self.provisioning_state = None + + +class CustomDomainResource(ProxyResource): + """Custom domain resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Properties of the custom domain resource. + :vartype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainProperties + """ + + _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": "CustomDomainProperties"}, + } + + def __init__(self, *, properties: Optional["_models.CustomDomainProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the custom domain resource. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class CustomDomainResourceCollection(_serialization.Model): + """Collection compose of a custom domain resources list and a possible link for next page. + + :ivar value: The custom domain resources list. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :ivar next_link: The link to next page of custom domain list. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[CustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.CustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The custom domain resources list. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :keyword next_link: The link to next page of custom domain list. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CustomDomainValidatePayload(_serialization.Model): + """Custom domain validate payload. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name to be validated. Required. + :vartype name: str + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: str, **kwargs): + """ + :keyword name: Name to be validated. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class CustomDomainValidateResult(_serialization.Model): + """Validation result for custom domain. + + :ivar is_valid: Indicates if domain name is valid. + :vartype is_valid: bool + :ivar message: Message of why domain name is invalid. + :vartype message: str + """ + + _attribute_map = { + "is_valid": {"key": "isValid", "type": "bool"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, is_valid: Optional[bool] = None, message: Optional[str] = None, **kwargs): + """ + :keyword is_valid: Indicates if domain name is valid. + :paramtype is_valid: bool + :keyword message: Message of why domain name is invalid. + :paramtype message: str + """ + super().__init__(**kwargs) + self.is_valid = is_valid + self.message = message + + +class CustomPersistentDiskResource(_serialization.Model): + """Custom persistent disk resource payload. + + All required parameters must be populated in order to send to Azure. + + :ivar custom_persistent_disk_properties: Properties of the custom persistent disk resource + payload. + :vartype custom_persistent_disk_properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomPersistentDiskProperties + :ivar storage_id: The resource id of Azure Spring Apps Storage resource. Required. + :vartype storage_id: str + """ + + _validation = { + "storage_id": {"required": True}, + } + + _attribute_map = { + "custom_persistent_disk_properties": { + "key": "customPersistentDiskProperties", + "type": "CustomPersistentDiskProperties", + }, + "storage_id": {"key": "storageId", "type": "str"}, + } + + def __init__( + self, + *, + storage_id: str, + custom_persistent_disk_properties: Optional["_models.CustomPersistentDiskProperties"] = None, + **kwargs + ): + """ + :keyword custom_persistent_disk_properties: Properties of the custom persistent disk resource + payload. + :paramtype custom_persistent_disk_properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomPersistentDiskProperties + :keyword storage_id: The resource id of Azure Spring Apps Storage resource. Required. + :paramtype storage_id: str + """ + super().__init__(**kwargs) + self.custom_persistent_disk_properties = custom_persistent_disk_properties + self.storage_id = storage_id + + +class DeploymentInstance(_serialization.Model): + """Deployment instance payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the deployment instance. + :vartype name: str + :ivar status: Status of the deployment instance. + :vartype status: str + :ivar reason: Failed reason of the deployment instance. + :vartype reason: str + :ivar discovery_status: Discovery status of the deployment instance. + :vartype discovery_status: str + :ivar start_time: Start time of the deployment instance. + :vartype start_time: str + :ivar zone: Availability zone information of the deployment instance. + :vartype zone: str + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + "reason": {"readonly": True}, + "discovery_status": {"readonly": True}, + "start_time": {"readonly": True}, + "zone": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "discovery_status": {"key": "discoveryStatus", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, + "zone": {"key": "zone", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + self.reason = None + self.discovery_status = None + self.start_time = None + self.zone = None + + +class DeploymentList(_serialization.Model): + """A list of deployments resource ids. + + :ivar deployments: A list of deployment resource ids. + :vartype deployments: list[str] + """ + + _attribute_map = { + "deployments": {"key": "deployments", "type": "[str]"}, + } + + def __init__(self, *, deployments: Optional[List[str]] = None, **kwargs): + """ + :keyword deployments: A list of deployment resource ids. + :paramtype deployments: list[str] + """ + super().__init__(**kwargs) + self.deployments = deployments + + +class DeploymentResource(ProxyResource): + """Deployment resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Properties of the Deployment resource. + :vartype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResourceProperties + :ivar sku: Sku of the Deployment resource. + :vartype sku: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Sku + """ + + _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": "DeploymentResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, + } + + def __init__( + self, + *, + properties: Optional["_models.DeploymentResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword properties: Properties of the Deployment resource. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResourceProperties + :keyword sku: Sku of the Deployment resource. + :paramtype sku: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Sku + """ + super().__init__(**kwargs) + self.properties = properties + self.sku = sku + + +class DeploymentResourceCollection(_serialization.Model): + """Object that includes an array of App resources and a possible link for next set. + + :ivar value: Collection of Deployment resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[DeploymentResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.DeploymentResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of Deployment resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class DeploymentResourceProperties(_serialization.Model): + """Deployment resource properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar source: Uploaded source information of the deployment. + :vartype source: ~azure.mgmt.appplatform.v2022_09_01_preview.models.UserSourceInfo + :ivar deployment_settings: Deployment settings of the Deployment. + :vartype deployment_settings: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentSettings + :ivar provisioning_state: Provisioning state of the Deployment. Known values are: "Creating", + "Updating", "Succeeded", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResourceProvisioningState + :ivar status: Status of the Deployment. Known values are: "Stopped" and "Running". + :vartype status: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResourceStatus + :ivar active: Indicates whether the Deployment is active. + :vartype active: bool + :ivar instances: Collection of instances belong to the Deployment. + :vartype instances: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentInstance] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "instances": {"readonly": True}, + } + + _attribute_map = { + "source": {"key": "source", "type": "UserSourceInfo"}, + "deployment_settings": {"key": "deploymentSettings", "type": "DeploymentSettings"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "active": {"key": "active", "type": "bool"}, + "instances": {"key": "instances", "type": "[DeploymentInstance]"}, + } + + def __init__( + self, + *, + source: Optional["_models.UserSourceInfo"] = None, + deployment_settings: Optional["_models.DeploymentSettings"] = None, + active: Optional[bool] = None, + **kwargs + ): + """ + :keyword source: Uploaded source information of the deployment. + :paramtype source: ~azure.mgmt.appplatform.v2022_09_01_preview.models.UserSourceInfo + :keyword deployment_settings: Deployment settings of the Deployment. + :paramtype deployment_settings: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentSettings + :keyword active: Indicates whether the Deployment is active. + :paramtype active: bool + """ + super().__init__(**kwargs) + self.source = source + self.deployment_settings = deployment_settings + self.provisioning_state = None + self.status = None + self.active = active + self.instances = None + + +class DeploymentSettings(_serialization.Model): + """Deployment settings payload. + + :ivar resource_requests: The requested resource quantity for required CPU and Memory. It is + recommended that using this field to represent the required CPU and Memory, the old field cpu + and memoryInGB will be deprecated later. + :vartype resource_requests: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceRequests + :ivar environment_variables: Collection of environment variables. + :vartype environment_variables: dict[str, str] + :ivar addon_configs: Collection of addons. + :vartype addon_configs: dict[str, dict[str, JSON]] + :ivar liveness_probe: Periodic probe of App Instance liveness. App Instance will be restarted + if the probe fails. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :vartype liveness_probe: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Probe + :ivar readiness_probe: Periodic probe of App Instance service readiness. App Instance will be + removed from service endpoints if the probe fails. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :vartype readiness_probe: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Probe + :ivar startup_probe: StartupProbe indicates that the App Instance has successfully initialized. + If specified, no other probes are executed until this completes successfully. If this probe + fails, the Pod will be restarted, just as if the livenessProbe failed. This can be used to + provide different probe parameters at the beginning of a App Instance's lifecycle, when it + might take a long time to load data or warm a cache, than during steady-state operation. This + cannot be updated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :vartype startup_probe: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Probe + :ivar termination_grace_period_seconds: Optional duration in seconds the App Instance needs to + terminate gracefully. May be decreased in delete request. Value must be non-negative integer. + The value zero indicates stop immediately via the kill signal (no opportunity to shut down). If + this value is nil, the default grace period will be used instead. The grace period is the + duration in seconds after the processes running in the App Instance are sent a termination + signal and the time when the processes are forcibly halted with a kill signal. Set this value + longer than the expected cleanup time for your process. Defaults to 90 seconds. + :vartype termination_grace_period_seconds: int + :ivar container_probe_settings: Container liveness and readiness probe settings. + :vartype container_probe_settings: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ContainerProbeSettings + """ + + _attribute_map = { + "resource_requests": {"key": "resourceRequests", "type": "ResourceRequests"}, + "environment_variables": {"key": "environmentVariables", "type": "{str}"}, + "addon_configs": {"key": "addonConfigs", "type": "{{object}}"}, + "liveness_probe": {"key": "livenessProbe", "type": "Probe"}, + "readiness_probe": {"key": "readinessProbe", "type": "Probe"}, + "startup_probe": {"key": "startupProbe", "type": "Probe"}, + "termination_grace_period_seconds": {"key": "terminationGracePeriodSeconds", "type": "int"}, + "container_probe_settings": {"key": "containerProbeSettings", "type": "ContainerProbeSettings"}, + } + + def __init__( + self, + *, + resource_requests: Optional["_models.ResourceRequests"] = None, + environment_variables: Optional[Dict[str, str]] = None, + addon_configs: Optional[Dict[str, Dict[str, JSON]]] = None, + liveness_probe: Optional["_models.Probe"] = None, + readiness_probe: Optional["_models.Probe"] = None, + startup_probe: Optional["_models.Probe"] = None, + termination_grace_period_seconds: int = 90, + container_probe_settings: Optional["_models.ContainerProbeSettings"] = None, + **kwargs + ): + """ + :keyword resource_requests: The requested resource quantity for required CPU and Memory. It is + recommended that using this field to represent the required CPU and Memory, the old field cpu + and memoryInGB will be deprecated later. + :paramtype resource_requests: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceRequests + :keyword environment_variables: Collection of environment variables. + :paramtype environment_variables: dict[str, str] + :keyword addon_configs: Collection of addons. + :paramtype addon_configs: dict[str, dict[str, JSON]] + :keyword liveness_probe: Periodic probe of App Instance liveness. App Instance will be + restarted if the probe fails. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :paramtype liveness_probe: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Probe + :keyword readiness_probe: Periodic probe of App Instance service readiness. App Instance will + be removed from service endpoints if the probe fails. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :paramtype readiness_probe: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Probe + :keyword startup_probe: StartupProbe indicates that the App Instance has successfully + initialized. If specified, no other probes are executed until this completes successfully. If + this probe fails, the Pod will be restarted, just as if the livenessProbe failed. This can be + used to provide different probe parameters at the beginning of a App Instance's lifecycle, when + it might take a long time to load data or warm a cache, than during steady-state operation. + This cannot be updated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :paramtype startup_probe: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Probe + :keyword termination_grace_period_seconds: Optional duration in seconds the App Instance needs + to terminate gracefully. May be decreased in delete request. Value must be non-negative + integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut + down). If this value is nil, the default grace period will be used instead. The grace period is + the duration in seconds after the processes running in the App Instance are sent a termination + signal and the time when the processes are forcibly halted with a kill signal. Set this value + longer than the expected cleanup time for your process. Defaults to 90 seconds. + :paramtype termination_grace_period_seconds: int + :keyword container_probe_settings: Container liveness and readiness probe settings. + :paramtype container_probe_settings: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ContainerProbeSettings + """ + super().__init__(**kwargs) + self.resource_requests = resource_requests + self.environment_variables = environment_variables + self.addon_configs = addon_configs + self.liveness_probe = liveness_probe + self.readiness_probe = readiness_probe + self.startup_probe = startup_probe + self.termination_grace_period_seconds = termination_grace_period_seconds + self.container_probe_settings = container_probe_settings + + +class DiagnosticParameters(_serialization.Model): + """Diagnostic parameters of diagnostic operations. + + :ivar app_instance: App instance name. + :vartype app_instance: str + :ivar file_path: Your target file path in your own BYOS. + :vartype file_path: str + :ivar duration: Duration of your JFR. 1 min can be represented by 1m or 60s. + :vartype duration: str + """ + + _attribute_map = { + "app_instance": {"key": "appInstance", "type": "str"}, + "file_path": {"key": "filePath", "type": "str"}, + "duration": {"key": "duration", "type": "str"}, + } + + def __init__( + self, + *, + app_instance: Optional[str] = None, + file_path: Optional[str] = None, + duration: Optional[str] = None, + **kwargs + ): + """ + :keyword app_instance: App instance name. + :paramtype app_instance: str + :keyword file_path: Your target file path in your own BYOS. + :paramtype file_path: str + :keyword duration: Duration of your JFR. 1 min can be represented by 1m or 60s. + :paramtype duration: str + """ + super().__init__(**kwargs) + self.app_instance = app_instance + self.file_path = file_path + self.duration = duration + + +class Error(_serialization.Model): + """The error code compose of code and message. + + :ivar code: The code of error. + :vartype code: str + :ivar message: The message of error. + :vartype message: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + """ + :keyword code: The code of error. + :paramtype code: str + :keyword message: The message of error. + :paramtype message: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + + +class ProbeAction(_serialization.Model): + """The action of the probe. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ExecAction, HTTPGetAction, TCPSocketAction + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the action to take to perform the health check. Required. Known values + are: "HTTPGetAction", "TCPSocketAction", and "ExecAction". + :vartype type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.ProbeActionType + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + _subtype_map = { + "type": {"ExecAction": "ExecAction", "HTTPGetAction": "HTTPGetAction", "TCPSocketAction": "TCPSocketAction"} + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type = None # type: Optional[str] + + +class ExecAction(ProbeAction): + """ExecAction describes a "run in container" action. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the action to take to perform the health check. Required. Known values + are: "HTTPGetAction", "TCPSocketAction", and "ExecAction". + :vartype type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.ProbeActionType + :ivar command: Command is the command line to execute inside the container, the working + directory for the command is root ('/') in the container's filesystem. The command is not run + inside a shell, so traditional shell instructions ('|', etc) won't work. To use a shell, you + need to explicitly call out to that shell. Exit status of 0 is treated as live/healthy and + non-zero is unhealthy. + :vartype command: list[str] + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "command": {"key": "command", "type": "[str]"}, + } + + def __init__(self, *, command: Optional[List[str]] = None, **kwargs): + """ + :keyword command: Command is the command line to execute inside the container, the working + directory for the command is root ('/') in the container's filesystem. The command is not run + inside a shell, so traditional shell instructions ('|', etc) won't work. To use a shell, you + need to explicitly call out to that shell. Exit status of 0 is treated as live/healthy and + non-zero is unhealthy. + :paramtype command: list[str] + """ + super().__init__(**kwargs) + self.type = "ExecAction" # type: str + self.command = command + + +class GatewayApiMetadataProperties(_serialization.Model): + """API metadata property for Spring Cloud Gateway. + + :ivar title: Title describing the context of the APIs available on the Gateway instance + (default: ``Spring Cloud Gateway for K8S``\ ). + :vartype title: str + :ivar description: Detailed description of the APIs available on the Gateway instance (default: + ``Generated OpenAPI 3 document that describes the API routes configured.``\ ). + :vartype description: str + :ivar documentation: Location of additional documentation for the APIs available on the Gateway + instance. + :vartype documentation: str + :ivar version: Version of APIs available on this Gateway instance (default: ``unspecified``\ ). + :vartype version: str + :ivar server_url: Base URL that API consumers will use to access APIs on the Gateway instance. + :vartype server_url: str + """ + + _attribute_map = { + "title": {"key": "title", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "documentation": {"key": "documentation", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "server_url": {"key": "serverUrl", "type": "str"}, + } + + def __init__( + self, + *, + title: Optional[str] = None, + description: Optional[str] = None, + documentation: Optional[str] = None, + version: Optional[str] = None, + server_url: Optional[str] = None, + **kwargs + ): + """ + :keyword title: Title describing the context of the APIs available on the Gateway instance + (default: ``Spring Cloud Gateway for K8S``\ ). + :paramtype title: str + :keyword description: Detailed description of the APIs available on the Gateway instance + (default: ``Generated OpenAPI 3 document that describes the API routes configured.``\ ). + :paramtype description: str + :keyword documentation: Location of additional documentation for the APIs available on the + Gateway instance. + :paramtype documentation: str + :keyword version: Version of APIs available on this Gateway instance (default: ``unspecified``\ + ). + :paramtype version: str + :keyword server_url: Base URL that API consumers will use to access APIs on the Gateway + instance. + :paramtype server_url: str + """ + super().__init__(**kwargs) + self.title = title + self.description = description + self.documentation = documentation + self.version = version + self.server_url = server_url + + +class GatewayApiRoute(_serialization.Model): + """API route config of the Spring Cloud Gateway. + + :ivar title: A title, will be applied to methods in the generated OpenAPI documentation. + :vartype title: str + :ivar description: A description, will be applied to methods in the generated OpenAPI + documentation. + :vartype description: str + :ivar uri: Full uri, will override ``appName``. + :vartype uri: str + :ivar sso_enabled: Enable sso validation. + :vartype sso_enabled: bool + :ivar token_relay: Pass currently-authenticated user's identity token to application service, + default is 'false'. + :vartype token_relay: bool + :ivar predicates: A number of conditions to evaluate a route for each request. Each predicate + may be evaluated against request headers and parameter values. All of the predicates associated + with a route must evaluate to true for the route to be matched to the request. + :vartype predicates: list[str] + :ivar filters: To modify the request before sending it to the target endpoint, or the received + response. + :vartype filters: list[str] + :ivar order: Route processing order. + :vartype order: int + :ivar tags: Classification tags, will be applied to methods in the generated OpenAPI + documentation. + :vartype tags: list[str] + """ + + _attribute_map = { + "title": {"key": "title", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "sso_enabled": {"key": "ssoEnabled", "type": "bool"}, + "token_relay": {"key": "tokenRelay", "type": "bool"}, + "predicates": {"key": "predicates", "type": "[str]"}, + "filters": {"key": "filters", "type": "[str]"}, + "order": {"key": "order", "type": "int"}, + "tags": {"key": "tags", "type": "[str]"}, + } + + def __init__( + self, + *, + title: Optional[str] = None, + description: Optional[str] = None, + uri: Optional[str] = None, + sso_enabled: Optional[bool] = None, + token_relay: Optional[bool] = None, + predicates: Optional[List[str]] = None, + filters: Optional[List[str]] = None, + order: Optional[int] = None, + tags: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword title: A title, will be applied to methods in the generated OpenAPI documentation. + :paramtype title: str + :keyword description: A description, will be applied to methods in the generated OpenAPI + documentation. + :paramtype description: str + :keyword uri: Full uri, will override ``appName``. + :paramtype uri: str + :keyword sso_enabled: Enable sso validation. + :paramtype sso_enabled: bool + :keyword token_relay: Pass currently-authenticated user's identity token to application + service, default is 'false'. + :paramtype token_relay: bool + :keyword predicates: A number of conditions to evaluate a route for each request. Each + predicate may be evaluated against request headers and parameter values. All of the predicates + associated with a route must evaluate to true for the route to be matched to the request. + :paramtype predicates: list[str] + :keyword filters: To modify the request before sending it to the target endpoint, or the + received response. + :paramtype filters: list[str] + :keyword order: Route processing order. + :paramtype order: int + :keyword tags: Classification tags, will be applied to methods in the generated OpenAPI + documentation. + :paramtype tags: list[str] + """ + super().__init__(**kwargs) + self.title = title + self.description = description + self.uri = uri + self.sso_enabled = sso_enabled + self.token_relay = token_relay + self.predicates = predicates + self.filters = filters + self.order = order + self.tags = tags + + +class GatewayCorsProperties(_serialization.Model): + """Cross-Origin Resource Sharing property. + + :ivar allowed_origins: Allowed origins to make cross-site requests. The special value ``*`` + allows all domains. + :vartype allowed_origins: list[str] + :ivar allowed_methods: Allowed HTTP methods on cross-site requests. The special value ``*`` + allows all methods. If not set, ``GET`` and ``HEAD`` are allowed by default. + :vartype allowed_methods: list[str] + :ivar allowed_headers: Allowed headers in cross-site requests. The special value ``*`` allows + actual requests to send any header. + :vartype allowed_headers: list[str] + :ivar max_age: How long, in seconds, the response from a pre-flight request can be cached by + clients. + :vartype max_age: int + :ivar allow_credentials: Whether user credentials are supported on cross-site requests. Valid + values: ``true``\ , ``false``. + :vartype allow_credentials: bool + :ivar exposed_headers: HTTP response headers to expose for cross-site requests. + :vartype exposed_headers: list[str] + """ + + _attribute_map = { + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, + "max_age": {"key": "maxAge", "type": "int"}, + "allow_credentials": {"key": "allowCredentials", "type": "bool"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + } + + def __init__( + self, + *, + allowed_origins: Optional[List[str]] = None, + allowed_methods: Optional[List[str]] = None, + allowed_headers: Optional[List[str]] = None, + max_age: Optional[int] = None, + allow_credentials: Optional[bool] = None, + exposed_headers: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword allowed_origins: Allowed origins to make cross-site requests. The special value ``*`` + allows all domains. + :paramtype allowed_origins: list[str] + :keyword allowed_methods: Allowed HTTP methods on cross-site requests. The special value ``*`` + allows all methods. If not set, ``GET`` and ``HEAD`` are allowed by default. + :paramtype allowed_methods: list[str] + :keyword allowed_headers: Allowed headers in cross-site requests. The special value ``*`` + allows actual requests to send any header. + :paramtype allowed_headers: list[str] + :keyword max_age: How long, in seconds, the response from a pre-flight request can be cached by + clients. + :paramtype max_age: int + :keyword allow_credentials: Whether user credentials are supported on cross-site requests. + Valid values: ``true``\ , ``false``. + :paramtype allow_credentials: bool + :keyword exposed_headers: HTTP response headers to expose for cross-site requests. + :paramtype exposed_headers: list[str] + """ + super().__init__(**kwargs) + self.allowed_origins = allowed_origins + self.allowed_methods = allowed_methods + self.allowed_headers = allowed_headers + self.max_age = max_age + self.allow_credentials = allow_credentials + self.exposed_headers = exposed_headers + + +class GatewayCustomDomainProperties(_serialization.Model): + """The properties of custom domain for Spring Cloud Gateway. + + :ivar thumbprint: The thumbprint of bound certificate. + :vartype thumbprint: str + """ + + _attribute_map = { + "thumbprint": {"key": "thumbprint", "type": "str"}, + } + + def __init__(self, *, thumbprint: Optional[str] = None, **kwargs): + """ + :keyword thumbprint: The thumbprint of bound certificate. + :paramtype thumbprint: str + """ + super().__init__(**kwargs) + self.thumbprint = thumbprint + + +class GatewayCustomDomainResource(ProxyResource): + """Custom domain of the Spring Cloud Gateway. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: The properties of custom domain for Spring Cloud Gateway. + :vartype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainProperties + """ + + _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": "GatewayCustomDomainProperties"}, + } + + def __init__(self, *, properties: Optional["_models.GatewayCustomDomainProperties"] = None, **kwargs): + """ + :keyword properties: The properties of custom domain for Spring Cloud Gateway. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class GatewayCustomDomainResourceCollection(_serialization.Model): + """Object that includes an array of Spring Cloud Gateway custom domain resources and a possible link for next set. + + :ivar value: Collection of Spring Cloud Gateway custom domain resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GatewayCustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.GatewayCustomDomainResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of Spring Cloud Gateway custom domain resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GatewayInstance(_serialization.Model): + """Collection of instances belong to the Spring Cloud Gateway. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Spring Cloud Gateway instance. + :vartype name: str + :ivar status: Status of the Spring Cloud Gateway instance. + :vartype status: str + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + + +class GatewayOperatorProperties(_serialization.Model): + """Properties of the Spring Cloud Gateway Operator. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_requests: The requested resource quantity for required CPU and Memory. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayOperatorResourceRequests + :ivar instances: Collection of instances belong to Spring Cloud Gateway operator. + :vartype instances: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayInstance] + """ + + _validation = { + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, + } + + _attribute_map = { + "resource_requests": {"key": "resourceRequests", "type": "GatewayOperatorResourceRequests"}, + "instances": {"key": "instances", "type": "[GatewayInstance]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.resource_requests = None + self.instances = None + + +class GatewayOperatorResourceRequests(_serialization.Model): + """Properties of the Spring Cloud Gateway Operator. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: Cpu allocated to each Spring Cloud Gateway Operator instance. + :vartype cpu: str + :ivar memory: Memory allocated to each Spring Cloud Gateway Operator instance. + :vartype memory: str + :ivar instance_count: Instance count of the Spring Cloud Gateway Operator. + :vartype instance_count: int + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, + } + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.cpu = None + self.memory = None + self.instance_count = None + + +class GatewayProperties(_serialization.Model): + """Spring Cloud Gateway properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the Spring Cloud Gateway. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayProvisioningState + :ivar public: Indicates whether the Spring Cloud Gateway exposes endpoint. + :vartype public: bool + :ivar url: URL of the Spring Cloud Gateway, exposed when 'public' is true. + :vartype url: str + :ivar https_only: Indicate if only https is allowed. + :vartype https_only: bool + :ivar sso_properties: Single sign-on related configuration. + :vartype sso_properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SsoProperties + :ivar api_metadata_properties: API metadata property for Spring Cloud Gateway. + :vartype api_metadata_properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayApiMetadataProperties + :ivar cors_properties: Cross-Origin Resource Sharing property. + :vartype cors_properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCorsProperties + :ivar resource_requests: The requested resource quantity for required CPU and Memory. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResourceRequests + :ivar instances: Collection of instances belong to Spring Cloud Gateway. + :vartype instances: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayInstance] + :ivar operator_properties: Properties of the Spring Cloud Gateway Operator. + :vartype operator_properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayOperatorProperties + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "url": {"readonly": True}, + "instances": {"readonly": True}, + "operator_properties": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "sso_properties": {"key": "ssoProperties", "type": "SsoProperties"}, + "api_metadata_properties": {"key": "apiMetadataProperties", "type": "GatewayApiMetadataProperties"}, + "cors_properties": {"key": "corsProperties", "type": "GatewayCorsProperties"}, + "resource_requests": {"key": "resourceRequests", "type": "GatewayResourceRequests"}, + "instances": {"key": "instances", "type": "[GatewayInstance]"}, + "operator_properties": {"key": "operatorProperties", "type": "GatewayOperatorProperties"}, + } + + def __init__( + self, + *, + public: bool = False, + https_only: bool = False, + sso_properties: Optional["_models.SsoProperties"] = None, + api_metadata_properties: Optional["_models.GatewayApiMetadataProperties"] = None, + cors_properties: Optional["_models.GatewayCorsProperties"] = None, + resource_requests: Optional["_models.GatewayResourceRequests"] = None, + **kwargs + ): + """ + :keyword public: Indicates whether the Spring Cloud Gateway exposes endpoint. + :paramtype public: bool + :keyword https_only: Indicate if only https is allowed. + :paramtype https_only: bool + :keyword sso_properties: Single sign-on related configuration. + :paramtype sso_properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SsoProperties + :keyword api_metadata_properties: API metadata property for Spring Cloud Gateway. + :paramtype api_metadata_properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayApiMetadataProperties + :keyword cors_properties: Cross-Origin Resource Sharing property. + :paramtype cors_properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCorsProperties + :keyword resource_requests: The requested resource quantity for required CPU and Memory. + :paramtype resource_requests: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResourceRequests + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.public = public + self.url = None + self.https_only = https_only + self.sso_properties = sso_properties + self.api_metadata_properties = api_metadata_properties + self.cors_properties = cors_properties + self.resource_requests = resource_requests + self.instances = None + self.operator_properties = None + + +class GatewayResource(ProxyResource): + """Spring Cloud Gateway resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Spring Cloud Gateway properties payload. + :vartype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayProperties + :ivar sku: Sku of the Spring Cloud Gateway resource. + :vartype sku: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Sku + """ + + _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": "GatewayProperties"}, + "sku": {"key": "sku", "type": "Sku"}, + } + + def __init__( + self, *, properties: Optional["_models.GatewayProperties"] = None, sku: Optional["_models.Sku"] = None, **kwargs + ): + """ + :keyword properties: Spring Cloud Gateway properties payload. + :paramtype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayProperties + :keyword sku: Sku of the Spring Cloud Gateway resource. + :paramtype sku: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Sku + """ + super().__init__(**kwargs) + self.properties = properties + self.sku = sku + + +class GatewayResourceCollection(_serialization.Model): + """Object that includes an array of gateway resources and a possible link for next set. + + :ivar value: Collection of gateway resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GatewayResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.GatewayResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of gateway resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GatewayResourceRequests(_serialization.Model): + """Resource request payload of Spring Cloud Gateway. + + :ivar cpu: Cpu allocated to each Spring Cloud Gateway instance. + :vartype cpu: str + :ivar memory: Memory allocated to each Spring Cloud Gateway instance. + :vartype memory: str + """ + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + } + + def __init__(self, *, cpu: str = "1", memory: str = "2Gi", **kwargs): + """ + :keyword cpu: Cpu allocated to each Spring Cloud Gateway instance. + :paramtype cpu: str + :keyword memory: Memory allocated to each Spring Cloud Gateway instance. + :paramtype memory: str + """ + super().__init__(**kwargs) + self.cpu = cpu + self.memory = memory + + +class GatewayRouteConfigOpenApiProperties(_serialization.Model): + """OpenAPI properties of Spring Cloud Gateway route config. + + :ivar uri: The URI of OpenAPI specification. + :vartype uri: str + """ + + _attribute_map = { + "uri": {"key": "uri", "type": "str"}, + } + + def __init__(self, *, uri: Optional[str] = None, **kwargs): + """ + :keyword uri: The URI of OpenAPI specification. + :paramtype uri: str + """ + super().__init__(**kwargs) + self.uri = uri + + +class GatewayRouteConfigProperties(_serialization.Model): + """API route config of the Spring Cloud Gateway. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the Spring Cloud Gateway route config. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayProvisioningState + :ivar app_resource_id: The resource Id of the Azure Spring Apps app, required unless route + defines ``uri``. + :vartype app_resource_id: str + :ivar open_api: OpenAPI properties of Spring Cloud Gateway route config. + :vartype open_api: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigOpenApiProperties + :ivar protocol: Protocol of routed Azure Spring Apps applications. Known values are: "HTTP" and + "HTTPS". + :vartype protocol: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigProtocol + :ivar routes: Array of API routes, each route contains properties such as ``title``\ , ``uri``\ + , ``ssoEnabled``\ , ``predicates``\ , ``filters``. + :vartype routes: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayApiRoute] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "app_resource_id": {"key": "appResourceId", "type": "str"}, + "open_api": {"key": "openApi", "type": "GatewayRouteConfigOpenApiProperties"}, + "protocol": {"key": "protocol", "type": "str"}, + "routes": {"key": "routes", "type": "[GatewayApiRoute]"}, + } + + def __init__( + self, + *, + app_resource_id: Optional[str] = None, + open_api: Optional["_models.GatewayRouteConfigOpenApiProperties"] = None, + protocol: Union[str, "_models.GatewayRouteConfigProtocol"] = "HTTP", + routes: Optional[List["_models.GatewayApiRoute"]] = None, + **kwargs + ): + """ + :keyword app_resource_id: The resource Id of the Azure Spring Apps app, required unless route + defines ``uri``. + :paramtype app_resource_id: str + :keyword open_api: OpenAPI properties of Spring Cloud Gateway route config. + :paramtype open_api: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigOpenApiProperties + :keyword protocol: Protocol of routed Azure Spring Apps applications. Known values are: "HTTP" + and "HTTPS". + :paramtype protocol: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigProtocol + :keyword routes: Array of API routes, each route contains properties such as ``title``\ , + ``uri``\ , ``ssoEnabled``\ , ``predicates``\ , ``filters``. + :paramtype routes: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayApiRoute] + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.app_resource_id = app_resource_id + self.open_api = open_api + self.protocol = protocol + self.routes = routes + + +class GatewayRouteConfigResource(ProxyResource): + """Spring Cloud Gateway route config resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: API route config of the Spring Cloud Gateway. + :vartype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigProperties + """ + + _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": "GatewayRouteConfigProperties"}, + } + + def __init__(self, *, properties: Optional["_models.GatewayRouteConfigProperties"] = None, **kwargs): + """ + :keyword properties: API route config of the Spring Cloud Gateway. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class GatewayRouteConfigResourceCollection(_serialization.Model): + """Object that includes an array of Spring Cloud Gateway route config resources and a possible link for next set. + + :ivar value: Collection of Spring Cloud Gateway route config resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GatewayRouteConfigResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.GatewayRouteConfigResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of Spring Cloud Gateway route config resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GitPatternRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Git repository property payload for config server. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name of the repository. Required. + :vartype name: str + :ivar pattern: Collection of pattern of the repository. + :vartype pattern: list[str] + :ivar uri: URI of the repository. Required. + :vartype uri: str + :ivar label: Label of the repository. + :vartype label: str + :ivar search_paths: Searching path of the repository. + :vartype search_paths: list[str] + :ivar username: Username of git repository basic auth. + :vartype username: str + :ivar password: Password of git repository basic auth. + :vartype password: str + :ivar host_key: Public sshKey of git repository. + :vartype host_key: str + :ivar host_key_algorithm: SshKey algorithm of git repository. + :vartype host_key_algorithm: str + :ivar private_key: Private sshKey algorithm of git repository. + :vartype private_key: str + :ivar strict_host_key_checking: Strict host key checking or not. + :vartype strict_host_key_checking: bool + """ + + _validation = { + "name": {"required": True}, + "uri": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "pattern": {"key": "pattern", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, + } + + def __init__( + self, + *, + name: str, + uri: str, + pattern: Optional[List[str]] = None, + label: Optional[str] = None, + search_paths: Optional[List[str]] = None, + username: Optional[str] = None, + password: Optional[str] = None, + host_key: Optional[str] = None, + host_key_algorithm: Optional[str] = None, + private_key: Optional[str] = None, + strict_host_key_checking: Optional[bool] = None, + **kwargs + ): + """ + :keyword name: Name of the repository. Required. + :paramtype name: str + :keyword pattern: Collection of pattern of the repository. + :paramtype pattern: list[str] + :keyword uri: URI of the repository. Required. + :paramtype uri: str + :keyword label: Label of the repository. + :paramtype label: str + :keyword search_paths: Searching path of the repository. + :paramtype search_paths: list[str] + :keyword username: Username of git repository basic auth. + :paramtype username: str + :keyword password: Password of git repository basic auth. + :paramtype password: str + :keyword host_key: Public sshKey of git repository. + :paramtype host_key: str + :keyword host_key_algorithm: SshKey algorithm of git repository. + :paramtype host_key_algorithm: str + :keyword private_key: Private sshKey algorithm of git repository. + :paramtype private_key: str + :keyword strict_host_key_checking: Strict host key checking or not. + :paramtype strict_host_key_checking: bool + """ + super().__init__(**kwargs) + self.name = name + self.pattern = pattern + self.uri = uri + self.label = label + self.search_paths = search_paths + self.username = username + self.password = password + self.host_key = host_key + self.host_key_algorithm = host_key_algorithm + self.private_key = private_key + self.strict_host_key_checking = strict_host_key_checking + + +class HTTPGetAction(ProbeAction): + """HTTPGetAction describes an action based on HTTP Get requests. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the action to take to perform the health check. Required. Known values + are: "HTTPGetAction", "TCPSocketAction", and "ExecAction". + :vartype type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.ProbeActionType + :ivar path: Path to access on the HTTP server. + :vartype path: str + :ivar scheme: Scheme to use for connecting to the host. Defaults to HTTP. + + Possible enum values: + + + * ``"HTTP"`` means that the scheme used will be http:// + * ``"HTTPS"`` means that the scheme used will be https://. Known values are: "HTTP" and + "HTTPS". + :vartype scheme: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.HTTPSchemeType + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "path": {"key": "path", "type": "str"}, + "scheme": {"key": "scheme", "type": "str"}, + } + + def __init__( + self, *, path: Optional[str] = None, scheme: Optional[Union[str, "_models.HTTPSchemeType"]] = None, **kwargs + ): + """ + :keyword path: Path to access on the HTTP server. + :paramtype path: str + :keyword scheme: Scheme to use for connecting to the host. Defaults to HTTP. + + Possible enum values: + + + * ``"HTTP"`` means that the scheme used will be http:// + * ``"HTTPS"`` means that the scheme used will be https://. Known values are: "HTTP" and + "HTTPS". + :paramtype scheme: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.HTTPSchemeType + """ + super().__init__(**kwargs) + self.type = "HTTPGetAction" # type: str + self.path = path + self.scheme = scheme + + +class ImageRegistryCredential(_serialization.Model): + """Credential of the image registry. + + :ivar username: The username of the image registry credential. + :vartype username: str + :ivar password: The password of the image registry credential. + :vartype password: str + """ + + _attribute_map = { + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + } + + def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs): + """ + :keyword username: The username of the image registry credential. + :paramtype username: str + :keyword password: The password of the image registry credential. + :paramtype password: str + """ + super().__init__(**kwargs) + self.username = username + self.password = password + + +class IngressConfig(_serialization.Model): + """Ingress configuration payload for Azure Spring Apps resource. + + :ivar read_timeout_in_seconds: Ingress read time out in seconds. + :vartype read_timeout_in_seconds: int + """ + + _attribute_map = { + "read_timeout_in_seconds": {"key": "readTimeoutInSeconds", "type": "int"}, + } + + def __init__(self, *, read_timeout_in_seconds: Optional[int] = None, **kwargs): + """ + :keyword read_timeout_in_seconds: Ingress read time out in seconds. + :paramtype read_timeout_in_seconds: int + """ + super().__init__(**kwargs) + self.read_timeout_in_seconds = read_timeout_in_seconds + + +class IngressSettings(_serialization.Model): + """App ingress settings payload. + + :ivar read_timeout_in_seconds: Ingress read time out in seconds. + :vartype read_timeout_in_seconds: int + :ivar send_timeout_in_seconds: Ingress send time out in seconds. + :vartype send_timeout_in_seconds: int + :ivar session_affinity: Type of the affinity, set this to Cookie to enable session affinity. + Known values are: "Cookie" and "None". + :vartype session_affinity: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.SessionAffinity + :ivar session_cookie_max_age: Time in seconds until the cookie expires. + :vartype session_cookie_max_age: int + :ivar backend_protocol: How ingress should communicate with this app backend service. Known + values are: "GRPC" and "Default". + :vartype backend_protocol: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BackendProtocol + :ivar client_auth: Client-Certification Authentication. + :vartype client_auth: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.IngressSettingsClientAuth + """ + + _attribute_map = { + "read_timeout_in_seconds": {"key": "readTimeoutInSeconds", "type": "int"}, + "send_timeout_in_seconds": {"key": "sendTimeoutInSeconds", "type": "int"}, + "session_affinity": {"key": "sessionAffinity", "type": "str"}, + "session_cookie_max_age": {"key": "sessionCookieMaxAge", "type": "int"}, + "backend_protocol": {"key": "backendProtocol", "type": "str"}, + "client_auth": {"key": "clientAuth", "type": "IngressSettingsClientAuth"}, + } + + def __init__( + self, + *, + read_timeout_in_seconds: Optional[int] = None, + send_timeout_in_seconds: Optional[int] = None, + session_affinity: Optional[Union[str, "_models.SessionAffinity"]] = None, + session_cookie_max_age: Optional[int] = None, + backend_protocol: Optional[Union[str, "_models.BackendProtocol"]] = None, + client_auth: Optional["_models.IngressSettingsClientAuth"] = None, + **kwargs + ): + """ + :keyword read_timeout_in_seconds: Ingress read time out in seconds. + :paramtype read_timeout_in_seconds: int + :keyword send_timeout_in_seconds: Ingress send time out in seconds. + :paramtype send_timeout_in_seconds: int + :keyword session_affinity: Type of the affinity, set this to Cookie to enable session affinity. + Known values are: "Cookie" and "None". + :paramtype session_affinity: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.SessionAffinity + :keyword session_cookie_max_age: Time in seconds until the cookie expires. + :paramtype session_cookie_max_age: int + :keyword backend_protocol: How ingress should communicate with this app backend service. Known + values are: "GRPC" and "Default". + :paramtype backend_protocol: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BackendProtocol + :keyword client_auth: Client-Certification Authentication. + :paramtype client_auth: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.IngressSettingsClientAuth + """ + super().__init__(**kwargs) + self.read_timeout_in_seconds = read_timeout_in_seconds + self.send_timeout_in_seconds = send_timeout_in_seconds + self.session_affinity = session_affinity + self.session_cookie_max_age = session_cookie_max_age + self.backend_protocol = backend_protocol + self.client_auth = client_auth + + +class IngressSettingsClientAuth(_serialization.Model): + """Client-Certification Authentication. + + :ivar certificates: Collection of certificate resource id. + :vartype certificates: list[str] + """ + + _attribute_map = { + "certificates": {"key": "certificates", "type": "[str]"}, + } + + def __init__(self, *, certificates: Optional[List[str]] = None, **kwargs): + """ + :keyword certificates: Collection of certificate resource id. + :paramtype certificates: list[str] + """ + super().__init__(**kwargs) + self.certificates = certificates + + +class UploadedUserSourceInfo(UserSourceInfo): + """Source with uploaded location. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + JarUploadedUserSourceInfo, NetCoreZipUploadedUserSourceInfo, SourceUploadedUserSourceInfo + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the source uploaded. Required. + :vartype type: str + :ivar version: Version of the source. + :vartype version: str + :ivar relative_path: Relative path of the storage which stores the source. + :vartype relative_path: str + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + } + + _subtype_map = { + "type": { + "Jar": "JarUploadedUserSourceInfo", + "NetCoreZip": "NetCoreZipUploadedUserSourceInfo", + "Source": "SourceUploadedUserSourceInfo", + } + } + + def __init__(self, *, version: Optional[str] = None, relative_path: Optional[str] = None, **kwargs): + """ + :keyword version: Version of the source. + :paramtype version: str + :keyword relative_path: Relative path of the storage which stores the source. + :paramtype relative_path: str + """ + super().__init__(version=version, **kwargs) + self.type = "UploadedUserSourceInfo" # type: str + self.relative_path = relative_path + + +class JarUploadedUserSourceInfo(UploadedUserSourceInfo): + """Uploaded Jar binary for a deployment. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the source uploaded. Required. + :vartype type: str + :ivar version: Version of the source. + :vartype version: str + :ivar relative_path: Relative path of the storage which stores the source. + :vartype relative_path: str + :ivar runtime_version: Runtime version of the Jar file. + :vartype runtime_version: str + :ivar jvm_options: JVM parameter. + :vartype jvm_options: str + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, + "jvm_options": {"key": "jvmOptions", "type": "str"}, + } + + def __init__( + self, + *, + version: Optional[str] = None, + relative_path: Optional[str] = None, + runtime_version: Optional[str] = None, + jvm_options: Optional[str] = None, + **kwargs + ): + """ + :keyword version: Version of the source. + :paramtype version: str + :keyword relative_path: Relative path of the storage which stores the source. + :paramtype relative_path: str + :keyword runtime_version: Runtime version of the Jar file. + :paramtype runtime_version: str + :keyword jvm_options: JVM parameter. + :paramtype jvm_options: str + """ + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "Jar" # type: str + self.runtime_version = runtime_version + self.jvm_options = jvm_options + + +class KeyVaultCertificateProperties(CertificateProperties): # pylint: disable=too-many-instance-attributes + """Properties of certificate imported from key vault. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the certificate source. Required. + :vartype type: str + :ivar thumbprint: The thumbprint of certificate. + :vartype thumbprint: str + :ivar issuer: The issuer of certificate. + :vartype issuer: str + :ivar issued_date: The issue date of certificate. + :vartype issued_date: str + :ivar expiration_date: The expiration date of certificate. + :vartype expiration_date: str + :ivar activate_date: The activate date of certificate. + :vartype activate_date: str + :ivar subject_name: The subject name of certificate. + :vartype subject_name: str + :ivar dns_names: The domain list of certificate. + :vartype dns_names: list[str] + :ivar provisioning_state: Provisioning state of the Certificate. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResourceProvisioningState + :ivar vault_uri: The vault uri of user key vault. Required. + :vartype vault_uri: str + :ivar key_vault_cert_name: The certificate name of key vault. Required. + :vartype key_vault_cert_name: str + :ivar cert_version: The certificate version of key vault. + :vartype cert_version: str + :ivar exclude_private_key: Optional. If set to true, it will not import private key from key + vault. + :vartype exclude_private_key: bool + """ + + _validation = { + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "vault_uri": {"required": True}, + "key_vault_cert_name": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "vault_uri": {"key": "vaultUri", "type": "str"}, + "key_vault_cert_name": {"key": "keyVaultCertName", "type": "str"}, + "cert_version": {"key": "certVersion", "type": "str"}, + "exclude_private_key": {"key": "excludePrivateKey", "type": "bool"}, + } + + def __init__( + self, + *, + vault_uri: str, + key_vault_cert_name: str, + cert_version: Optional[str] = None, + exclude_private_key: bool = False, + **kwargs + ): + """ + :keyword vault_uri: The vault uri of user key vault. Required. + :paramtype vault_uri: str + :keyword key_vault_cert_name: The certificate name of key vault. Required. + :paramtype key_vault_cert_name: str + :keyword cert_version: The certificate version of key vault. + :paramtype cert_version: str + :keyword exclude_private_key: Optional. If set to true, it will not import private key from key + vault. + :paramtype exclude_private_key: bool + """ + super().__init__(**kwargs) + self.type = "KeyVaultCertificate" # type: str + self.vault_uri = vault_uri + self.key_vault_cert_name = key_vault_cert_name + self.cert_version = cert_version + self.exclude_private_key = exclude_private_key + + +class LoadedCertificate(_serialization.Model): + """Loaded certificate payload. + + All required parameters must be populated in order to send to Azure. + + :ivar resource_id: Resource Id of loaded certificate. Required. + :vartype resource_id: str + :ivar load_trust_store: Indicate whether the certificate will be loaded into default trust + store, only work for Java runtime. + :vartype load_trust_store: bool + """ + + _validation = { + "resource_id": {"required": True}, + } + + _attribute_map = { + "resource_id": {"key": "resourceId", "type": "str"}, + "load_trust_store": {"key": "loadTrustStore", "type": "bool"}, + } + + def __init__(self, *, resource_id: str, load_trust_store: bool = False, **kwargs): + """ + :keyword resource_id: Resource Id of loaded certificate. Required. + :paramtype resource_id: str + :keyword load_trust_store: Indicate whether the certificate will be loaded into default trust + store, only work for Java runtime. + :paramtype load_trust_store: bool + """ + super().__init__(**kwargs) + self.resource_id = resource_id + self.load_trust_store = load_trust_store + + +class LogFileUrlResponse(_serialization.Model): + """Log file URL payload. + + All required parameters must be populated in order to send to Azure. + + :ivar url: URL of the log file. Required. + :vartype url: str + """ + + _validation = { + "url": {"required": True}, + } + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + } + + def __init__(self, *, url: str, **kwargs): + """ + :keyword url: URL of the log file. Required. + :paramtype url: str + """ + super().__init__(**kwargs) + self.url = url + + +class LogSpecification(_serialization.Model): + """Specifications of the Log for Azure Monitoring. + + :ivar name: Name of the log. + :vartype name: str + :ivar display_name: Localized friendly display name of the log. + :vartype display_name: str + :ivar blob_duration: Blob duration of the log. + :vartype blob_duration: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + blob_duration: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Name of the log. + :paramtype name: str + :keyword display_name: Localized friendly display name of the log. + :paramtype display_name: str + :keyword blob_duration: Blob duration of the log. + :paramtype blob_duration: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.blob_duration = blob_duration + + +class ManagedIdentityProperties(_serialization.Model): + """Managed identity properties retrieved from ARM request headers. + + :ivar type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.ManagedIdentityType + :ivar principal_id: Principal Id of system-assigned managed identity. + :vartype principal_id: str + :ivar tenant_id: Tenant Id of system-assigned managed identity. + :vartype tenant_id: str + :ivar user_assigned_identities: Properties of user-assigned managed identities. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.appplatform.v2022_09_01_preview.models.UserAssignedManagedIdentity] + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedManagedIdentity}"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, + principal_id: Optional[str] = None, + tenant_id: Optional[str] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedManagedIdentity"]] = None, + **kwargs + ): + """ + :keyword type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". + :paramtype type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.ManagedIdentityType + :keyword principal_id: Principal Id of system-assigned managed identity. + :paramtype principal_id: str + :keyword tenant_id: Tenant Id of system-assigned managed identity. + :paramtype tenant_id: str + :keyword user_assigned_identities: Properties of user-assigned managed identities. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.appplatform.v2022_09_01_preview.models.UserAssignedManagedIdentity] + """ + super().__init__(**kwargs) + self.type = type + self.principal_id = principal_id + self.tenant_id = tenant_id + self.user_assigned_identities = user_assigned_identities + + +class MarketplaceResource(_serialization.Model): + """Purchasing 3rd Party product for one Azure Spring Apps instance. + + :ivar plan: The plan id of the 3rd Party Artifact that is being procured. + :vartype plan: str + :ivar publisher: The publisher id of the 3rd Party Artifact that is being bought. + :vartype publisher: str + :ivar product: The 3rd Party artifact that is being procured. + :vartype product: str + """ + + _attribute_map = { + "plan": {"key": "plan", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + } + + def __init__( + self, *, plan: Optional[str] = None, publisher: Optional[str] = None, product: Optional[str] = None, **kwargs + ): + """ + :keyword plan: The plan id of the 3rd Party Artifact that is being procured. + :paramtype plan: str + :keyword publisher: The publisher id of the 3rd Party Artifact that is being bought. + :paramtype publisher: str + :keyword product: The 3rd Party artifact that is being procured. + :paramtype product: str + """ + super().__init__(**kwargs) + self.plan = plan + self.publisher = publisher + self.product = product + + +class MetricDimension(_serialization.Model): + """Specifications of the Dimension of metrics. + + :ivar name: Name of the dimension. + :vartype name: str + :ivar display_name: Localized friendly display name of the dimension. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: Whether this dimension should be included for the Shoebox + export scenario. + :vartype to_be_exported_for_shoebox: bool + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + to_be_exported_for_shoebox: Optional[bool] = None, + **kwargs + ): + """ + :keyword name: Name of the dimension. + :paramtype name: str + :keyword display_name: Localized friendly display name of the dimension. + :paramtype display_name: str + :keyword to_be_exported_for_shoebox: Whether this dimension should be included for the Shoebox + export scenario. + :paramtype to_be_exported_for_shoebox: bool + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.to_be_exported_for_shoebox = to_be_exported_for_shoebox + + +class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Specifications of the Metrics for Azure Monitoring. + + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Localized friendly display name of the metric. + :vartype display_name: str + :ivar display_description: Localized friendly description of the metric. + :vartype display_description: str + :ivar unit: Unit that makes sense for the metric. + :vartype unit: str + :ivar category: Name of the metric category that the metric belongs to. A metric can only + belong to a single category. + :vartype category: str + :ivar aggregation_type: Only provide one value for this field. Valid values: Average, Minimum, + Maximum, Total, Count. + :vartype aggregation_type: str + :ivar supported_aggregation_types: Supported aggregation types. + :vartype supported_aggregation_types: list[str] + :ivar supported_time_grain_types: Supported time grain types. + :vartype supported_time_grain_types: list[str] + :ivar fill_gap_with_zero: Optional. If set to true, then zero will be returned for time + duration where no metric is emitted/published. + :vartype fill_gap_with_zero: bool + :ivar dimensions: Dimensions of the metric. + :vartype dimensions: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.MetricDimension] + :ivar source_mdm_namespace: Name of the MDM namespace. Optional. + :vartype source_mdm_namespace: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "source_mdm_namespace": {"key": "sourceMdmNamespace", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + unit: Optional[str] = None, + category: Optional[str] = None, + aggregation_type: Optional[str] = None, + supported_aggregation_types: Optional[List[str]] = None, + supported_time_grain_types: Optional[List[str]] = None, + fill_gap_with_zero: Optional[bool] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, + source_mdm_namespace: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Name of the metric. + :paramtype name: str + :keyword display_name: Localized friendly display name of the metric. + :paramtype display_name: str + :keyword display_description: Localized friendly description of the metric. + :paramtype display_description: str + :keyword unit: Unit that makes sense for the metric. + :paramtype unit: str + :keyword category: Name of the metric category that the metric belongs to. A metric can only + belong to a single category. + :paramtype category: str + :keyword aggregation_type: Only provide one value for this field. Valid values: Average, + Minimum, Maximum, Total, Count. + :paramtype aggregation_type: str + :keyword supported_aggregation_types: Supported aggregation types. + :paramtype supported_aggregation_types: list[str] + :keyword supported_time_grain_types: Supported time grain types. + :paramtype supported_time_grain_types: list[str] + :keyword fill_gap_with_zero: Optional. If set to true, then zero will be returned for time + duration where no metric is emitted/published. + :paramtype fill_gap_with_zero: bool + :keyword dimensions: Dimensions of the metric. + :paramtype dimensions: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.MetricDimension] + :keyword source_mdm_namespace: Name of the MDM namespace. Optional. + :paramtype source_mdm_namespace: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.display_description = display_description + self.unit = unit + self.category = category + self.aggregation_type = aggregation_type + self.supported_aggregation_types = supported_aggregation_types + self.supported_time_grain_types = supported_time_grain_types + self.fill_gap_with_zero = fill_gap_with_zero + self.dimensions = dimensions + self.source_mdm_namespace = source_mdm_namespace + + +class MonitoringSettingProperties(_serialization.Model): + """Monitoring Setting properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the Monitoring Setting. Known values are: "NotAvailable", + "Failed", "Succeeded", and "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingState + :ivar error: Error when apply Monitoring Setting changes. + :vartype error: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Error + :ivar trace_enabled: Indicates whether enable the trace functionality, which will be deprecated + since api version 2020-11-01-preview. Please leverage appInsightsInstrumentationKey to indicate + if monitoringSettings enabled or not. + :vartype trace_enabled: bool + :ivar app_insights_instrumentation_key: Target application insight instrumentation key, null or + whitespace include empty will disable monitoringSettings. + :vartype app_insights_instrumentation_key: str + :ivar app_insights_sampling_rate: Indicates the sampling rate of application insight agent, + should be in range [0.0, 100.0]. + :vartype app_insights_sampling_rate: float + :ivar app_insights_agent_versions: Indicates the versions of application insight agent. + :vartype app_insights_agent_versions: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApplicationInsightsAgentVersions + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "app_insights_sampling_rate": {"maximum": 100, "minimum": 0}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "trace_enabled": {"key": "traceEnabled", "type": "bool"}, + "app_insights_instrumentation_key": {"key": "appInsightsInstrumentationKey", "type": "str"}, + "app_insights_sampling_rate": {"key": "appInsightsSamplingRate", "type": "float"}, + "app_insights_agent_versions": {"key": "appInsightsAgentVersions", "type": "ApplicationInsightsAgentVersions"}, + } + + def __init__( + self, + *, + error: Optional["_models.Error"] = None, + trace_enabled: Optional[bool] = None, + app_insights_instrumentation_key: Optional[str] = None, + app_insights_sampling_rate: Optional[float] = None, + app_insights_agent_versions: Optional["_models.ApplicationInsightsAgentVersions"] = None, + **kwargs + ): + """ + :keyword error: Error when apply Monitoring Setting changes. + :paramtype error: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Error + :keyword trace_enabled: Indicates whether enable the trace functionality, which will be + deprecated since api version 2020-11-01-preview. Please leverage appInsightsInstrumentationKey + to indicate if monitoringSettings enabled or not. + :paramtype trace_enabled: bool + :keyword app_insights_instrumentation_key: Target application insight instrumentation key, null + or whitespace include empty will disable monitoringSettings. + :paramtype app_insights_instrumentation_key: str + :keyword app_insights_sampling_rate: Indicates the sampling rate of application insight agent, + should be in range [0.0, 100.0]. + :paramtype app_insights_sampling_rate: float + :keyword app_insights_agent_versions: Indicates the versions of application insight agent. + :paramtype app_insights_agent_versions: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApplicationInsightsAgentVersions + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.error = error + self.trace_enabled = trace_enabled + self.app_insights_instrumentation_key = app_insights_instrumentation_key + self.app_insights_sampling_rate = app_insights_sampling_rate + self.app_insights_agent_versions = app_insights_agent_versions + + +class MonitoringSettingResource(ProxyResource): + """Monitoring Setting resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Properties of the Monitoring Setting resource. + :vartype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingProperties + """ + + _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": "MonitoringSettingProperties"}, + } + + def __init__(self, *, properties: Optional["_models.MonitoringSettingProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the Monitoring Setting resource. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class NameAvailability(_serialization.Model): + """Name availability result payload. + + :ivar name_available: Indicates whether the name is available. + :vartype name_available: bool + :ivar reason: Reason why the name is not available. + :vartype reason: str + :ivar message: Message why the name is not available. + :vartype message: str + """ + + _attribute_map = { + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__( + self, + *, + name_available: Optional[bool] = None, + reason: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword name_available: Indicates whether the name is available. + :paramtype name_available: bool + :keyword reason: Reason why the name is not available. + :paramtype reason: str + :keyword message: Message why the name is not available. + :paramtype message: str + """ + super().__init__(**kwargs) + self.name_available = name_available + self.reason = reason + self.message = message + + +class NameAvailabilityParameters(_serialization.Model): + """Name availability parameters payload. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the resource to check name availability. Required. + :vartype type: str + :ivar name: Name to be checked. Required. + :vartype name: str + """ + + _validation = { + "type": {"required": True}, + "name": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, type: str, name: str, **kwargs): + """ + :keyword type: Type of the resource to check name availability. Required. + :paramtype type: str + :keyword name: Name to be checked. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.type = type + self.name = name + + +class NetCoreZipUploadedUserSourceInfo(UploadedUserSourceInfo): + """Uploaded Jar binary for a deployment. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the source uploaded. Required. + :vartype type: str + :ivar version: Version of the source. + :vartype version: str + :ivar relative_path: Relative path of the storage which stores the source. + :vartype relative_path: str + :ivar net_core_main_entry_path: The path to the .NET executable relative to zip root. + :vartype net_core_main_entry_path: str + :ivar runtime_version: Runtime version of the .Net file. + :vartype runtime_version: str + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "net_core_main_entry_path": {"key": "netCoreMainEntryPath", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, + } + + def __init__( + self, + *, + version: Optional[str] = None, + relative_path: Optional[str] = None, + net_core_main_entry_path: Optional[str] = None, + runtime_version: Optional[str] = None, + **kwargs + ): + """ + :keyword version: Version of the source. + :paramtype version: str + :keyword relative_path: Relative path of the storage which stores the source. + :paramtype relative_path: str + :keyword net_core_main_entry_path: The path to the .NET executable relative to zip root. + :paramtype net_core_main_entry_path: str + :keyword runtime_version: Runtime version of the .Net file. + :paramtype runtime_version: str + """ + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "NetCoreZip" # type: str + self.net_core_main_entry_path = net_core_main_entry_path + self.runtime_version = runtime_version + + +class NetworkProfile(_serialization.Model): + """Service network profile payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar service_runtime_subnet_id: Fully qualified resource Id of the subnet to host Azure Spring + Apps Service Runtime. + :vartype service_runtime_subnet_id: str + :ivar app_subnet_id: Fully qualified resource Id of the subnet to host customer apps in Azure + Spring Apps. + :vartype app_subnet_id: str + :ivar service_cidr: Azure Spring Apps service reserved CIDR. + :vartype service_cidr: str + :ivar service_runtime_network_resource_group: Name of the resource group containing network + resources of Azure Spring Apps Service Runtime. + :vartype service_runtime_network_resource_group: str + :ivar app_network_resource_group: Name of the resource group containing network resources for + customer apps in Azure Spring Apps. + :vartype app_network_resource_group: str + :ivar outbound_i_ps: Desired outbound IP resources for Azure Spring Apps resource. + :vartype outbound_i_ps: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.NetworkProfileOutboundIPs + :ivar required_traffics: Required inbound or outbound traffics for Azure Spring Apps resource. + :vartype required_traffics: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.RequiredTraffic] + :ivar ingress_config: Ingress configuration payload for Azure Spring Apps resource. + :vartype ingress_config: ~azure.mgmt.appplatform.v2022_09_01_preview.models.IngressConfig + :ivar outbound_type: The egress traffic type of Azure Spring Apps VNet instances. + :vartype outbound_type: str + """ + + _validation = { + "outbound_i_ps": {"readonly": True}, + "required_traffics": {"readonly": True}, + } + + _attribute_map = { + "service_runtime_subnet_id": {"key": "serviceRuntimeSubnetId", "type": "str"}, + "app_subnet_id": {"key": "appSubnetId", "type": "str"}, + "service_cidr": {"key": "serviceCidr", "type": "str"}, + "service_runtime_network_resource_group": {"key": "serviceRuntimeNetworkResourceGroup", "type": "str"}, + "app_network_resource_group": {"key": "appNetworkResourceGroup", "type": "str"}, + "outbound_i_ps": {"key": "outboundIPs", "type": "NetworkProfileOutboundIPs"}, + "required_traffics": {"key": "requiredTraffics", "type": "[RequiredTraffic]"}, + "ingress_config": {"key": "ingressConfig", "type": "IngressConfig"}, + "outbound_type": {"key": "outboundType", "type": "str"}, + } + + def __init__( + self, + *, + service_runtime_subnet_id: Optional[str] = None, + app_subnet_id: Optional[str] = None, + service_cidr: Optional[str] = None, + service_runtime_network_resource_group: Optional[str] = None, + app_network_resource_group: Optional[str] = None, + ingress_config: Optional["_models.IngressConfig"] = None, + outbound_type: Optional[str] = None, + **kwargs + ): + """ + :keyword service_runtime_subnet_id: Fully qualified resource Id of the subnet to host Azure + Spring Apps Service Runtime. + :paramtype service_runtime_subnet_id: str + :keyword app_subnet_id: Fully qualified resource Id of the subnet to host customer apps in + Azure Spring Apps. + :paramtype app_subnet_id: str + :keyword service_cidr: Azure Spring Apps service reserved CIDR. + :paramtype service_cidr: str + :keyword service_runtime_network_resource_group: Name of the resource group containing network + resources of Azure Spring Apps Service Runtime. + :paramtype service_runtime_network_resource_group: str + :keyword app_network_resource_group: Name of the resource group containing network resources + for customer apps in Azure Spring Apps. + :paramtype app_network_resource_group: str + :keyword ingress_config: Ingress configuration payload for Azure Spring Apps resource. + :paramtype ingress_config: ~azure.mgmt.appplatform.v2022_09_01_preview.models.IngressConfig + :keyword outbound_type: The egress traffic type of Azure Spring Apps VNet instances. + :paramtype outbound_type: str + """ + super().__init__(**kwargs) + self.service_runtime_subnet_id = service_runtime_subnet_id + self.app_subnet_id = app_subnet_id + self.service_cidr = service_cidr + self.service_runtime_network_resource_group = service_runtime_network_resource_group + self.app_network_resource_group = app_network_resource_group + self.outbound_i_ps = None + self.required_traffics = None + self.ingress_config = ingress_config + self.outbound_type = outbound_type + + +class NetworkProfileOutboundIPs(_serialization.Model): + """Desired outbound IP resources for Azure Spring Apps resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar public_i_ps: A list of public IP addresses. + :vartype public_i_ps: list[str] + """ + + _validation = { + "public_i_ps": {"readonly": True}, + } + + _attribute_map = { + "public_i_ps": {"key": "publicIPs", "type": "[str]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.public_i_ps = None + + +class OperationDetail(_serialization.Model): + """Operation detail payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the operation. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: Display of the operation. + :vartype display: ~azure.mgmt.appplatform.v2022_09_01_preview.models.OperationDisplay + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.ActionType + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar properties: Properties of the operation. + :vartype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.OperationProperties + """ + + _validation = { + "action_type": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "action_type": {"key": "actionType", "type": "str"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "OperationProperties"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[bool] = None, + display: Optional["_models.OperationDisplay"] = None, + origin: Optional[str] = None, + properties: Optional["_models.OperationProperties"] = None, + **kwargs + ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: Display of the operation. + :paramtype display: ~azure.mgmt.appplatform.v2022_09_01_preview.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword properties: Properties of the operation. + :paramtype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.OperationProperties + """ + super().__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + self.action_type = None + self.origin = origin + self.properties = properties + + +class OperationDisplay(_serialization.Model): + """Operation display payload. + + :ivar provider: Resource provider of the operation. + :vartype provider: str + :ivar resource: Resource of the operation. + :vartype resource: str + :ivar operation: Localized friendly name for the operation. + :vartype operation: str + :ivar description: Localized friendly description for the operation. + :vartype description: str + """ + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Resource provider of the operation. + :paramtype provider: str + :keyword resource: Resource of the operation. + :paramtype resource: str + :keyword operation: Localized friendly name for the operation. + :paramtype operation: str + :keyword description: Localized friendly description for the operation. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationProperties(_serialization.Model): + """Extra Operation properties. + + :ivar service_specification: Service specifications of the operation. + :vartype service_specification: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceSpecification + """ + + _attribute_map = { + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, + } + + def __init__(self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs): + """ + :keyword service_specification: Service specifications of the operation. + :paramtype service_specification: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceSpecification + """ + super().__init__(**kwargs) + self.service_specification = service_specification + + +class PersistentDisk(_serialization.Model): + """Persistent disk payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar size_in_gb: Size of the persistent disk in GB. + :vartype size_in_gb: int + :ivar used_in_gb: Size of the used persistent disk in GB. + :vartype used_in_gb: int + :ivar mount_path: Mount path of the persistent disk. + :vartype mount_path: str + """ + + _validation = { + "size_in_gb": {"maximum": 50, "minimum": 0}, + "used_in_gb": {"readonly": True, "maximum": 50, "minimum": 0}, + } + + _attribute_map = { + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "used_in_gb": {"key": "usedInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, + } + + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: Optional[str] = None, **kwargs): + """ + :keyword size_in_gb: Size of the persistent disk in GB. + :paramtype size_in_gb: int + :keyword mount_path: Mount path of the persistent disk. + :paramtype mount_path: str + """ + super().__init__(**kwargs) + self.size_in_gb = size_in_gb + self.used_in_gb = None + self.mount_path = mount_path + + +class Probe(_serialization.Model): + """Probe describes a health check to be performed against an App Instance to determine whether it is alive or ready to receive traffic. + + All required parameters must be populated in order to send to Azure. + + :ivar probe_action: The action of the probe. + :vartype probe_action: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ProbeAction + :ivar disable_probe: Indicate whether the probe is disabled. Required. + :vartype disable_probe: bool + :ivar initial_delay_seconds: Number of seconds after the App Instance has started before probes + are initiated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :vartype initial_delay_seconds: int + :ivar period_seconds: How often (in seconds) to perform the probe. Minimum value is 1. + :vartype period_seconds: int + :ivar timeout_seconds: Number of seconds after which the probe times out. Minimum value is 1. + :vartype timeout_seconds: int + :ivar failure_threshold: Minimum consecutive failures for the probe to be considered failed + after having succeeded. Minimum value is 1. + :vartype failure_threshold: int + :ivar success_threshold: Minimum consecutive successes for the probe to be considered + successful after having failed. Must be 1 for liveness and startup. Minimum value is 1. + :vartype success_threshold: int + """ + + _validation = { + "disable_probe": {"required": True}, + } + + _attribute_map = { + "probe_action": {"key": "probeAction", "type": "ProbeAction"}, + "disable_probe": {"key": "disableProbe", "type": "bool"}, + "initial_delay_seconds": {"key": "initialDelaySeconds", "type": "int"}, + "period_seconds": {"key": "periodSeconds", "type": "int"}, + "timeout_seconds": {"key": "timeoutSeconds", "type": "int"}, + "failure_threshold": {"key": "failureThreshold", "type": "int"}, + "success_threshold": {"key": "successThreshold", "type": "int"}, + } + + def __init__( + self, + *, + disable_probe: bool = False, + probe_action: Optional["_models.ProbeAction"] = None, + initial_delay_seconds: Optional[int] = None, + period_seconds: Optional[int] = None, + timeout_seconds: Optional[int] = None, + failure_threshold: Optional[int] = None, + success_threshold: Optional[int] = None, + **kwargs + ): + """ + :keyword probe_action: The action of the probe. + :paramtype probe_action: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ProbeAction + :keyword disable_probe: Indicate whether the probe is disabled. Required. + :paramtype disable_probe: bool + :keyword initial_delay_seconds: Number of seconds after the App Instance has started before + probes are initiated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :paramtype initial_delay_seconds: int + :keyword period_seconds: How often (in seconds) to perform the probe. Minimum value is 1. + :paramtype period_seconds: int + :keyword timeout_seconds: Number of seconds after which the probe times out. Minimum value is + 1. + :paramtype timeout_seconds: int + :keyword failure_threshold: Minimum consecutive failures for the probe to be considered failed + after having succeeded. Minimum value is 1. + :paramtype failure_threshold: int + :keyword success_threshold: Minimum consecutive successes for the probe to be considered + successful after having failed. Must be 1 for liveness and startup. Minimum value is 1. + :paramtype success_threshold: int + """ + super().__init__(**kwargs) + self.probe_action = probe_action + self.disable_probe = disable_probe + self.initial_delay_seconds = initial_delay_seconds + self.period_seconds = period_seconds + self.timeout_seconds = timeout_seconds + self.failure_threshold = failure_threshold + self.success_threshold = success_threshold + + +class RegenerateTestKeyRequestPayload(_serialization.Model): + """Regenerate test key request payload. + + All required parameters must be populated in order to send to Azure. + + :ivar key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". + :vartype key_type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.TestKeyType + """ + + _validation = { + "key_type": {"required": True}, + } + + _attribute_map = { + "key_type": {"key": "keyType", "type": "str"}, + } + + def __init__(self, *, key_type: Union[str, "_models.TestKeyType"], **kwargs): + """ + :keyword key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". + :paramtype key_type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.TestKeyType + """ + super().__init__(**kwargs) + self.key_type = key_type + + +class RemoteDebugging(_serialization.Model): + """Remote debugging config. + + :ivar port: Application debugging port. + :vartype port: int + :ivar enabled: Indicate if remote debugging is enabled. + :vartype enabled: bool + """ + + _attribute_map = { + "port": {"key": "port", "type": "int"}, + "enabled": {"key": "enabled", "type": "bool"}, + } + + def __init__(self, *, port: Optional[int] = None, enabled: Optional[bool] = None, **kwargs): + """ + :keyword port: Application debugging port. + :paramtype port: int + :keyword enabled: Indicate if remote debugging is enabled. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.port = port + self.enabled = enabled + + +class RemoteDebuggingPayload(_serialization.Model): + """Remote debugging payload. + + :ivar port: Application debugging port. + :vartype port: int + """ + + _attribute_map = { + "port": {"key": "port", "type": "int"}, + } + + def __init__(self, *, port: Optional[int] = None, **kwargs): + """ + :keyword port: Application debugging port. + :paramtype port: int + """ + super().__init__(**kwargs) + self.port = port + + +class RequiredTraffic(_serialization.Model): + """Required inbound or outbound traffic for Azure Spring Apps resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar protocol: The protocol of required traffic. + :vartype protocol: str + :ivar port: The port of required traffic. + :vartype port: int + :ivar ips: The ip list of required traffic. + :vartype ips: list[str] + :ivar fqdns: The FQDN list of required traffic. + :vartype fqdns: list[str] + :ivar direction: The direction of required traffic. Known values are: "Inbound" and "Outbound". + :vartype direction: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.TrafficDirection + """ + + _validation = { + "protocol": {"readonly": True}, + "port": {"readonly": True}, + "ips": {"readonly": True}, + "fqdns": {"readonly": True}, + "direction": {"readonly": True}, + } + + _attribute_map = { + "protocol": {"key": "protocol", "type": "str"}, + "port": {"key": "port", "type": "int"}, + "ips": {"key": "ips", "type": "[str]"}, + "fqdns": {"key": "fqdns", "type": "[str]"}, + "direction": {"key": "direction", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.protocol = None + self.port = None + self.ips = None + self.fqdns = None + self.direction = None + + +class ResourceRequests(_serialization.Model): + """Deployment resource request payload. + + :ivar cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 for + Basic tier, and {500m, 1, 2, 3, 4} for Standard tier. + :vartype cpu: str + :ivar memory: Required memory. 1 GB can be represented by 1Gi or 1024Mi. This should be {512Mi, + 1Gi, 2Gi} for Basic tier, and {512Mi, 1Gi, 2Gi, ..., 8Gi} for Standard tier. + :vartype memory: str + """ + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + } + + def __init__(self, *, cpu: Optional[str] = None, memory: Optional[str] = None, **kwargs): + """ + :keyword cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 + for Basic tier, and {500m, 1, 2, 3, 4} for Standard tier. + :paramtype cpu: str + :keyword memory: Required memory. 1 GB can be represented by 1Gi or 1024Mi. This should be + {512Mi, 1Gi, 2Gi} for Basic tier, and {512Mi, 1Gi, 2Gi, ..., 8Gi} for Standard tier. + :paramtype memory: str + """ + super().__init__(**kwargs) + self.cpu = cpu + self.memory = memory + + +class ResourceSku(_serialization.Model): + """Describes an available Azure Spring Apps SKU. + + :ivar resource_type: Gets the type of resource the SKU applies to. + :vartype resource_type: str + :ivar name: Gets the name of SKU. + :vartype name: str + :ivar tier: Gets the tier of SKU. + :vartype tier: str + :ivar capacity: Gets the capacity of SKU. + :vartype capacity: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SkuCapacity + :ivar locations: Gets the set of locations that the SKU is available. + :vartype locations: list[str] + :ivar location_info: Gets a list of locations and availability zones in those locations where + the SKU is available. + :vartype location_info: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSkuLocationInfo] + :ivar restrictions: Gets the restrictions because of which SKU cannot be used. This is + empty if there are no restrictions. + :vartype restrictions: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSkuRestrictions] + """ + + _attribute_map = { + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "SkuCapacity"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[ResourceSkuLocationInfo]"}, + "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, + } + + def __init__( + self, + *, + resource_type: Optional[str] = None, + name: Optional[str] = None, + tier: Optional[str] = None, + capacity: Optional["_models.SkuCapacity"] = None, + locations: Optional[List[str]] = None, + location_info: Optional[List["_models.ResourceSkuLocationInfo"]] = None, + restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None, + **kwargs + ): + """ + :keyword resource_type: Gets the type of resource the SKU applies to. + :paramtype resource_type: str + :keyword name: Gets the name of SKU. + :paramtype name: str + :keyword tier: Gets the tier of SKU. + :paramtype tier: str + :keyword capacity: Gets the capacity of SKU. + :paramtype capacity: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SkuCapacity + :keyword locations: Gets the set of locations that the SKU is available. + :paramtype locations: list[str] + :keyword location_info: Gets a list of locations and availability zones in those locations + where the SKU is available. + :paramtype location_info: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSkuLocationInfo] + :keyword restrictions: Gets the restrictions because of which SKU cannot be used. This is + empty if there are no restrictions. + :paramtype restrictions: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSkuRestrictions] + """ + super().__init__(**kwargs) + self.resource_type = resource_type + self.name = name + self.tier = tier + self.capacity = capacity + self.locations = locations + self.location_info = location_info + self.restrictions = restrictions + + +class ResourceSkuCapabilities(_serialization.Model): + """ResourceSkuCapabilities. + + :ivar name: Gets an invariant to describe the feature. + :vartype name: str + :ivar value: Gets an invariant if the feature is measured by quantity. + :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: Gets an invariant to describe the feature. + :paramtype name: str + :keyword value: Gets an invariant if the feature is measured by quantity. + :paramtype value: str + """ + super().__init__(**kwargs) + self.name = name + self.value = value + + +class ResourceSkuCollection(_serialization.Model): + """Object that includes an array of Azure Spring Apps SKU and a possible link for next set. + + :ivar value: Collection of resource SKU. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSku] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ResourceSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.ResourceSku"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of resource SKU. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSku] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ResourceSkuLocationInfo(_serialization.Model): + """Locations and availability zones where the SKU is available. + + :ivar location: Gets location of the SKU. + :vartype location: str + :ivar zones: Gets list of availability zones where the SKU is supported. + :vartype zones: list[str] + :ivar zone_details: Gets details of capabilities available to a SKU in specific zones. + :vartype zone_details: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSkuZoneDetails] + """ + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "zone_details": {"key": "zoneDetails", "type": "[ResourceSkuZoneDetails]"}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + zones: Optional[List[str]] = None, + zone_details: Optional[List["_models.ResourceSkuZoneDetails"]] = None, + **kwargs + ): + """ + :keyword location: Gets location of the SKU. + :paramtype location: str + :keyword zones: Gets list of availability zones where the SKU is supported. + :paramtype zones: list[str] + :keyword zone_details: Gets details of capabilities available to a SKU in specific zones. + :paramtype zone_details: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSkuZoneDetails] + """ + super().__init__(**kwargs) + self.location = location + self.zones = zones + self.zone_details = zone_details + + +class ResourceSkuRestrictionInfo(_serialization.Model): + """Information about the restriction where the SKU cannot be used. + + :ivar locations: Gets locations where the SKU is restricted. + :vartype locations: list[str] + :ivar zones: Gets list of availability zones where the SKU is restricted. + :vartype zones: list[str] + """ + + _attribute_map = { + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, + } + + def __init__(self, *, locations: Optional[List[str]] = None, zones: Optional[List[str]] = None, **kwargs): + """ + :keyword locations: Gets locations where the SKU is restricted. + :paramtype locations: list[str] + :keyword zones: Gets list of availability zones where the SKU is restricted. + :paramtype zones: list[str] + """ + super().__init__(**kwargs) + self.locations = locations + self.zones = zones + + +class ResourceSkuRestrictions(_serialization.Model): + """Restrictions where the SKU cannot be used. + + :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. Known + values are: "Location" and "Zone". + :vartype type: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSkuRestrictionsType + :ivar values: Gets the value of restrictions. If the restriction type is set to + location. This would be different locations where the SKU is restricted. + :vartype values: list[str] + :ivar restriction_info: Gets the information about the restriction where the SKU cannot be + used. + :vartype restriction_info: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSkuRestrictionInfo + :ivar reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". + :vartype reason_code: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSkuRestrictionsReasonCode + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "restriction_info": {"key": "restrictionInfo", "type": "ResourceSkuRestrictionInfo"}, + "reason_code": {"key": "reasonCode", "type": "str"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None, + values: Optional[List[str]] = None, + restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None, + reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None, + **kwargs + ): + """ + :keyword type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. + Known values are: "Location" and "Zone". + :paramtype type: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSkuRestrictionsType + :keyword values: Gets the value of restrictions. If the restriction type is set to + location. This would be different locations where the SKU is restricted. + :paramtype values: list[str] + :keyword restriction_info: Gets the information about the restriction where the SKU cannot be + used. + :paramtype restriction_info: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSkuRestrictionInfo + :keyword reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". + :paramtype reason_code: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSkuRestrictionsReasonCode + """ + super().__init__(**kwargs) + self.type = type + self.values = values + self.restriction_info = restriction_info + self.reason_code = reason_code + + +class ResourceSkuZoneDetails(_serialization.Model): + """Details of capabilities available to a SKU in specific zones. + + :ivar name: Gets the set of zones that the SKU is available in with the + specified capabilities. + :vartype name: list[str] + :ivar capabilities: Gets a list of capabilities that are available for the SKU in the + specified list of zones. + :vartype capabilities: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSkuCapabilities] + """ + + _attribute_map = { + "name": {"key": "name", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, + } + + def __init__( + self, + *, + name: Optional[List[str]] = None, + capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None, + **kwargs + ): + """ + :keyword name: Gets the set of zones that the SKU is available in with the + specified capabilities. + :paramtype name: list[str] + :keyword capabilities: Gets a list of capabilities that are available for the SKU in the + specified list of zones. + :paramtype capabilities: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSkuCapabilities] + """ + super().__init__(**kwargs) + self.name = name + self.capabilities = capabilities + + +class ResourceUploadDefinition(_serialization.Model): + """Resource upload definition payload. + + :ivar relative_path: Source relative path. + :vartype relative_path: str + :ivar upload_url: Upload URL. + :vartype upload_url: str + """ + + _attribute_map = { + "relative_path": {"key": "relativePath", "type": "str"}, + "upload_url": {"key": "uploadUrl", "type": "str"}, + } + + def __init__(self, *, relative_path: Optional[str] = None, upload_url: Optional[str] = None, **kwargs): + """ + :keyword relative_path: Source relative path. + :paramtype relative_path: str + :keyword upload_url: Upload URL. + :paramtype upload_url: str + """ + super().__init__(**kwargs) + self.relative_path = relative_path + self.upload_url = upload_url + + +class ServiceRegistryInstance(_serialization.Model): + """Collection of instances belong to the Service Registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Service Registry instance. + :vartype name: str + :ivar status: Status of the Service Registry instance. + :vartype status: str + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + + +class ServiceRegistryProperties(_serialization.Model): + """Service Registry properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the Service Registry. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceRegistryProvisioningState + :ivar resource_requests: The requested resource quantity for required CPU and Memory. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceRegistryResourceRequests + :ivar instances: Collection of instances belong to Service Registry. + :vartype instances: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceRegistryInstance] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "ServiceRegistryResourceRequests"}, + "instances": {"key": "instances", "type": "[ServiceRegistryInstance]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.provisioning_state = None + self.resource_requests = None + self.instances = None + + +class ServiceRegistryResource(ProxyResource): + """Service Registry resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Service Registry properties payload. + :vartype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceRegistryProperties + """ + + _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": "ServiceRegistryProperties"}, + } + + def __init__(self, *, properties: Optional["_models.ServiceRegistryProperties"] = None, **kwargs): + """ + :keyword properties: Service Registry properties payload. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceRegistryProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ServiceRegistryResourceCollection(_serialization.Model): + """Object that includes an array of Service Registry resources and a possible link for next set. + + :ivar value: Collection of Service Registry resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceRegistryResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ServiceRegistryResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ServiceRegistryResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of Service Registry resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceRegistryResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ServiceRegistryResourceRequests(_serialization.Model): + """Resource request payload of Service Registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: Cpu allocated to each Service Registry instance. + :vartype cpu: str + :ivar memory: Memory allocated to each Service Registry instance. + :vartype memory: str + :ivar instance_count: Instance count of the Service Registry. + :vartype instance_count: int + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, + } + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.cpu = None + self.memory = None + self.instance_count = None + + +class TrackedResource(Resource): + """The resource model definition for a ARM tracked top level resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar location: The GEO location of the resource. + :vartype location: str + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + """ + + _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"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword location: The GEO location of the resource. + :paramtype location: str + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.location = location + self.tags = tags + + +class ServiceResource(TrackedResource): + """Service resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar location: The GEO location of the resource. + :vartype location: str + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + :ivar properties: Properties of the Service resource. + :vartype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ClusterResourceProperties + :ivar sku: Sku of the Service resource. + :vartype sku: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Sku + """ + + _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"}, + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "ClusterResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.ClusterResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword location: The GEO location of the resource. + :paramtype location: str + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. + :paramtype tags: dict[str, str] + :keyword properties: Properties of the Service resource. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ClusterResourceProperties + :keyword sku: Sku of the Service resource. + :paramtype sku: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Sku + """ + super().__init__(location=location, tags=tags, **kwargs) + self.properties = properties + self.sku = sku + + +class ServiceResourceList(_serialization.Model): + """Object that includes an array of Service resources and a possible link for next set. + + :ivar value: Collection of Service resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.ServiceResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of Service resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ServiceSpecification(_serialization.Model): + """Service specification payload. + + :ivar log_specifications: Specifications of the Log for Azure Monitoring. + :vartype log_specifications: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.LogSpecification] + :ivar metric_specifications: Specifications of the Metrics for Azure Monitoring. + :vartype metric_specifications: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.MetricSpecification] + """ + + _attribute_map = { + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, + } + + def __init__( + self, + *, + log_specifications: Optional[List["_models.LogSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, + **kwargs + ): + """ + :keyword log_specifications: Specifications of the Log for Azure Monitoring. + :paramtype log_specifications: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.LogSpecification] + :keyword metric_specifications: Specifications of the Metrics for Azure Monitoring. + :paramtype metric_specifications: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.MetricSpecification] + """ + super().__init__(**kwargs) + self.log_specifications = log_specifications + self.metric_specifications = metric_specifications + + +class ServiceVNetAddons(_serialization.Model): + """Additional Service settings in vnet injection instance. + + :ivar log_stream_public_endpoint: Indicates whether the log stream in vnet injection instance + could be accessed from internet. + :vartype log_stream_public_endpoint: bool + """ + + _attribute_map = { + "log_stream_public_endpoint": {"key": "logStreamPublicEndpoint", "type": "bool"}, + } + + def __init__(self, *, log_stream_public_endpoint: bool = False, **kwargs): + """ + :keyword log_stream_public_endpoint: Indicates whether the log stream in vnet injection + instance could be accessed from internet. + :paramtype log_stream_public_endpoint: bool + """ + super().__init__(**kwargs) + self.log_stream_public_endpoint = log_stream_public_endpoint + + +class Sku(_serialization.Model): + """Sku of Azure Spring Apps. + + :ivar name: Name of the Sku. + :vartype name: str + :ivar tier: Tier of the Sku. + :vartype tier: str + :ivar capacity: Current capacity of the target resource. + :vartype capacity: int + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, + } + + def __init__(self, *, name: str = "S0", tier: str = "Standard", capacity: Optional[int] = None, **kwargs): + """ + :keyword name: Name of the Sku. + :paramtype name: str + :keyword tier: Tier of the Sku. + :paramtype tier: str + :keyword capacity: Current capacity of the target resource. + :paramtype capacity: int + """ + super().__init__(**kwargs) + self.name = name + self.tier = tier + self.capacity = capacity + + +class SkuCapacity(_serialization.Model): + """The SKU capacity. + + All required parameters must be populated in order to send to Azure. + + :ivar minimum: Gets or sets the minimum. Required. + :vartype minimum: int + :ivar maximum: Gets or sets the maximum. + :vartype maximum: int + :ivar default: Gets or sets the default. + :vartype default: int + :ivar scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", and + "Automatic". + :vartype scale_type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.SkuScaleType + """ + + _validation = { + "minimum": {"required": True}, + } + + _attribute_map = { + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, + } + + def __init__( + self, + *, + minimum: int, + maximum: Optional[int] = None, + default: Optional[int] = None, + scale_type: Optional[Union[str, "_models.SkuScaleType"]] = None, + **kwargs + ): + """ + :keyword minimum: Gets or sets the minimum. Required. + :paramtype minimum: int + :keyword maximum: Gets or sets the maximum. + :paramtype maximum: int + :keyword default: Gets or sets the default. + :paramtype default: int + :keyword scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", + and "Automatic". + :paramtype scale_type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.SkuScaleType + """ + super().__init__(**kwargs) + self.minimum = minimum + self.maximum = maximum + self.default = default + self.scale_type = scale_type + + +class SourceUploadedUserSourceInfo(UploadedUserSourceInfo): + """Uploaded Java source code binary for a deployment. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the source uploaded. Required. + :vartype type: str + :ivar version: Version of the source. + :vartype version: str + :ivar relative_path: Relative path of the storage which stores the source. + :vartype relative_path: str + :ivar artifact_selector: Selector for the artifact to be used for the deployment for + multi-module projects. This should be + the relative path to the target module/project. + :vartype artifact_selector: str + :ivar runtime_version: Runtime version of the source file. + :vartype runtime_version: str + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "artifact_selector": {"key": "artifactSelector", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, + } + + def __init__( + self, + *, + version: Optional[str] = None, + relative_path: Optional[str] = None, + artifact_selector: Optional[str] = None, + runtime_version: Optional[str] = None, + **kwargs + ): + """ + :keyword version: Version of the source. + :paramtype version: str + :keyword relative_path: Relative path of the storage which stores the source. + :paramtype relative_path: str + :keyword artifact_selector: Selector for the artifact to be used for the deployment for + multi-module projects. This should be + the relative path to the target module/project. + :paramtype artifact_selector: str + :keyword runtime_version: Runtime version of the source file. + :paramtype runtime_version: str + """ + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "Source" # type: str + self.artifact_selector = artifact_selector + self.runtime_version = runtime_version + + +class SsoProperties(_serialization.Model): + """Single sign-on related configuration. + + :ivar scope: It defines the specific actions applications can be allowed to do on a user's + behalf. + :vartype scope: list[str] + :ivar client_id: The public identifier for the application. + :vartype client_id: str + :ivar client_secret: The secret known only to the application and the authorization server. + :vartype client_secret: str + :ivar issuer_uri: The URI of Issuer Identifier. + :vartype issuer_uri: str + """ + + _attribute_map = { + "scope": {"key": "scope", "type": "[str]"}, + "client_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, + "issuer_uri": {"key": "issuerUri", "type": "str"}, + } + + def __init__( + self, + *, + scope: Optional[List[str]] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + issuer_uri: Optional[str] = None, + **kwargs + ): + """ + :keyword scope: It defines the specific actions applications can be allowed to do on a user's + behalf. + :paramtype scope: list[str] + :keyword client_id: The public identifier for the application. + :paramtype client_id: str + :keyword client_secret: The secret known only to the application and the authorization server. + :paramtype client_secret: str + :keyword issuer_uri: The URI of Issuer Identifier. + :paramtype issuer_uri: str + """ + super().__init__(**kwargs) + self.scope = scope + self.client_id = client_id + self.client_secret = client_secret + self.issuer_uri = issuer_uri + + +class StackProperties(_serialization.Model): + """KPack ClusterStack properties payload. + + :ivar id: Id of the ClusterStack. + :vartype id: str + :ivar version: Version of the ClusterStack. + :vartype version: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__( + self, *, id: Optional[str] = None, version: Optional[str] = None, **kwargs # pylint: disable=redefined-builtin + ): + """ + :keyword id: Id of the ClusterStack. + :paramtype id: str + :keyword version: Version of the ClusterStack. + :paramtype version: str + """ + super().__init__(**kwargs) + self.id = id + self.version = version + + +class StorageProperties(_serialization.Model): + """Storage resource payload. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + StorageAccount + + All required parameters must be populated in order to send to Azure. + + :ivar storage_type: The type of the storage. Required. "StorageAccount" + :vartype storage_type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageType + """ + + _validation = { + "storage_type": {"required": True}, + } + + _attribute_map = { + "storage_type": {"key": "storageType", "type": "str"}, + } + + _subtype_map = {"storage_type": {"StorageAccount": "StorageAccount"}} + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.storage_type = None # type: Optional[str] + + +class StorageAccount(StorageProperties): + """storage resource of type Azure Storage Account. + + All required parameters must be populated in order to send to Azure. + + :ivar storage_type: The type of the storage. Required. "StorageAccount" + :vartype storage_type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageType + :ivar account_name: The account name of the Azure Storage Account. Required. + :vartype account_name: str + :ivar account_key: The account key of the Azure Storage Account. Required. + :vartype account_key: str + """ + + _validation = { + "storage_type": {"required": True}, + "account_name": {"required": True}, + "account_key": {"required": True}, + } + + _attribute_map = { + "storage_type": {"key": "storageType", "type": "str"}, + "account_name": {"key": "accountName", "type": "str"}, + "account_key": {"key": "accountKey", "type": "str"}, + } + + def __init__(self, *, account_name: str, account_key: str, **kwargs): + """ + :keyword account_name: The account name of the Azure Storage Account. Required. + :paramtype account_name: str + :keyword account_key: The account key of the Azure Storage Account. Required. + :paramtype account_key: str + """ + super().__init__(**kwargs) + self.storage_type = "StorageAccount" # type: str + self.account_name = account_name + self.account_key = account_key + + +class StorageResource(ProxyResource): + """Storage resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Properties of the storage resource payload. + :vartype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageProperties + """ + + _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": "StorageProperties"}, + } + + def __init__(self, *, properties: Optional["_models.StorageProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the storage resource payload. + :paramtype properties: ~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class StorageResourceCollection(_serialization.Model): + """Collection compose of storage resources list and a possible link for next page. + + :ivar value: The storage resources list. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource] + :ivar next_link: The link to next page of storage list. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[StorageResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.StorageResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The storage resources list. + :paramtype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource] + :keyword next_link: The link to next page of storage list. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SupportedBuildpackResource(ProxyResource): + """Supported buildpack resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Supported buildpack resource properties. + :vartype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedBuildpackResourceProperties + """ + + _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": "SupportedBuildpackResourceProperties"}, + } + + def __init__(self, *, properties: Optional["_models.SupportedBuildpackResourceProperties"] = None, **kwargs): + """ + :keyword properties: Supported buildpack resource properties. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedBuildpackResourceProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class SupportedBuildpackResourceProperties(_serialization.Model): + """Supported buildpack resource properties. + + :ivar buildpack_id: The id of supported buildpack. + :vartype buildpack_id: str + """ + + _attribute_map = { + "buildpack_id": {"key": "buildpackId", "type": "str"}, + } + + def __init__(self, *, buildpack_id: Optional[str] = None, **kwargs): + """ + :keyword buildpack_id: The id of supported buildpack. + :paramtype buildpack_id: str + """ + super().__init__(**kwargs) + self.buildpack_id = buildpack_id + + +class SupportedBuildpacksCollection(_serialization.Model): + """Object that includes an array of supported buildpacks resources and a possible link for next set. + + :ivar value: Collection of supported buildpacks resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedBuildpackResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SupportedBuildpackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.SupportedBuildpackResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of supported buildpacks resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedBuildpackResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SupportedRuntimeVersion(_serialization.Model): + """Supported deployment runtime version descriptor. + + :ivar value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", "Java_17", and "NetCore_31". + :vartype value: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedRuntimeValue + :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). Known + values are: "Java" and ".NET Core". + :vartype platform: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedRuntimePlatform + :ivar version: The detailed version (major.minor) of the platform. + :vartype version: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + "platform": {"key": "platform", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[Union[str, "_models.SupportedRuntimeValue"]] = None, + platform: Optional[Union[str, "_models.SupportedRuntimePlatform"]] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", "Java_17", and "NetCore_31". + :paramtype value: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedRuntimeValue + :keyword platform: The platform of this runtime version (possible values: "Java" or ".NET"). + Known values are: "Java" and ".NET Core". + :paramtype platform: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedRuntimePlatform + :keyword version: The detailed version (major.minor) of the platform. + :paramtype version: str + """ + super().__init__(**kwargs) + self.value = value + self.platform = platform + self.version = version + + +class SupportedStackResource(ProxyResource): + """Supported stack resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SystemData + :ivar properties: Supported stack resource properties. + :vartype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedStackResourceProperties + """ + + _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": "SupportedStackResourceProperties"}, + } + + def __init__(self, *, properties: Optional["_models.SupportedStackResourceProperties"] = None, **kwargs): + """ + :keyword properties: Supported stack resource properties. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedStackResourceProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class SupportedStackResourceProperties(_serialization.Model): + """Supported stack resource properties. + + :ivar stack_id: The id of supported stack. + :vartype stack_id: str + :ivar version: The version of supported stack. + :vartype version: str + """ + + _attribute_map = { + "stack_id": {"key": "stackId", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__(self, *, stack_id: Optional[str] = None, version: Optional[str] = None, **kwargs): + """ + :keyword stack_id: The id of supported stack. + :paramtype stack_id: str + :keyword version: The version of supported stack. + :paramtype version: str + """ + super().__init__(**kwargs) + self.stack_id = stack_id + self.version = version + + +class SupportedStacksCollection(_serialization.Model): + """Object that includes an array of supported stacks resources and a possible link for next set. + + :ivar value: Collection of supported stacks resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedStackResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SupportedStackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.SupportedStackResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of supported stacks resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedStackResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.LastModifiedByType + :ivar last_modified_at: The timestamp of resource modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.appplatform.v2022_09_01_preview.models.LastModifiedByType + :keyword last_modified_at: The timestamp of resource modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class TCPSocketAction(ProbeAction): + """TCPSocketAction describes an action based on opening a socket. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the action to take to perform the health check. Required. Known values + are: "HTTPGetAction", "TCPSocketAction", and "ExecAction". + :vartype type: str or ~azure.mgmt.appplatform.v2022_09_01_preview.models.ProbeActionType + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type = "TCPSocketAction" # type: str + + +class TemporaryDisk(_serialization.Model): + """Temporary disk payload. + + :ivar size_in_gb: Size of the temporary disk in GB. + :vartype size_in_gb: int + :ivar mount_path: Mount path of the temporary disk. + :vartype mount_path: str + """ + + _validation = { + "size_in_gb": {"maximum": 5, "minimum": 0}, + } + + _attribute_map = { + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, + } + + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: str = "/tmp", **kwargs): + """ + :keyword size_in_gb: Size of the temporary disk in GB. + :paramtype size_in_gb: int + :keyword mount_path: Mount path of the temporary disk. + :paramtype mount_path: str + """ + super().__init__(**kwargs) + self.size_in_gb = size_in_gb + self.mount_path = mount_path + + +class TestKeys(_serialization.Model): + """Test keys payload. + + :ivar primary_key: Primary key. + :vartype primary_key: str + :ivar secondary_key: Secondary key. + :vartype secondary_key: str + :ivar primary_test_endpoint: Primary test endpoint. + :vartype primary_test_endpoint: str + :ivar secondary_test_endpoint: Secondary test endpoint. + :vartype secondary_test_endpoint: str + :ivar enabled: Indicates whether the test endpoint feature enabled or not. + :vartype enabled: bool + """ + + _attribute_map = { + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "primary_test_endpoint": {"key": "primaryTestEndpoint", "type": "str"}, + "secondary_test_endpoint": {"key": "secondaryTestEndpoint", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + } + + def __init__( + self, + *, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + primary_test_endpoint: Optional[str] = None, + secondary_test_endpoint: Optional[str] = None, + enabled: Optional[bool] = None, + **kwargs + ): + """ + :keyword primary_key: Primary key. + :paramtype primary_key: str + :keyword secondary_key: Secondary key. + :paramtype secondary_key: str + :keyword primary_test_endpoint: Primary test endpoint. + :paramtype primary_test_endpoint: str + :keyword secondary_test_endpoint: Secondary test endpoint. + :paramtype secondary_test_endpoint: str + :keyword enabled: Indicates whether the test endpoint feature enabled or not. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.primary_key = primary_key + self.secondary_key = secondary_key + self.primary_test_endpoint = primary_test_endpoint + self.secondary_test_endpoint = secondary_test_endpoint + self.enabled = enabled + + +class TriggeredBuildResult(_serialization.Model): + """The build result triggered by a build. + + :ivar id: The unique build id of this build result. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: The unique build id of this build result. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class UserAssignedManagedIdentity(_serialization.Model): + """The details of the user-assigned managed identity assigned to an App. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: Principal Id of user-assigned managed identity. + :vartype principal_id: str + :ivar client_id: Client Id of user-assigned managed identity. + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class ValidationMessages(_serialization.Model): + """Validate messages of the configuration service git repositories. + + :ivar name: The name of the configuration service git repository. + :vartype name: str + :ivar messages: Detailed validation messages. + :vartype messages: list[str] + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, + } + + def __init__(self, *, name: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs): + """ + :keyword name: The name of the configuration service git repository. + :paramtype name: str + :keyword messages: Detailed validation messages. + :paramtype messages: list[str] + """ + super().__init__(**kwargs) + self.name = name + self.messages = messages diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/models/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/__init__.py new file mode 100644 index 000000000000..57694a8d82f6 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/__init__.py @@ -0,0 +1,63 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._services_operations import ServicesOperations +from ._config_servers_operations import ConfigServersOperations +from ._configuration_services_operations import ConfigurationServicesOperations +from ._service_registries_operations import ServiceRegistriesOperations +from ._build_service_operations import BuildServiceOperations +from ._buildpack_binding_operations import BuildpackBindingOperations +from ._build_service_builder_operations import BuildServiceBuilderOperations +from ._build_service_agent_pool_operations import BuildServiceAgentPoolOperations +from ._monitoring_settings_operations import MonitoringSettingsOperations +from ._apps_operations import AppsOperations +from ._bindings_operations import BindingsOperations +from ._storages_operations import StoragesOperations +from ._certificates_operations import CertificatesOperations +from ._custom_domains_operations import CustomDomainsOperations +from ._deployments_operations import DeploymentsOperations +from ._operations import Operations +from ._runtime_versions_operations import RuntimeVersionsOperations +from ._skus_operations import SkusOperations +from ._gateways_operations import GatewaysOperations +from ._gateway_route_configs_operations import GatewayRouteConfigsOperations +from ._gateway_custom_domains_operations import GatewayCustomDomainsOperations +from ._api_portals_operations import ApiPortalsOperations +from ._api_portal_custom_domains_operations import ApiPortalCustomDomainsOperations + +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__ = [ + "ServicesOperations", + "ConfigServersOperations", + "ConfigurationServicesOperations", + "ServiceRegistriesOperations", + "BuildServiceOperations", + "BuildpackBindingOperations", + "BuildServiceBuilderOperations", + "BuildServiceAgentPoolOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "StoragesOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", + "GatewaysOperations", + "GatewayRouteConfigsOperations", + "GatewayCustomDomainsOperations", + "ApiPortalsOperations", + "ApiPortalCustomDomainsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_api_portal_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_api_portal_custom_domains_operations.py new file mode 100644 index 000000000000..649c2f43ed44 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_api_portal_custom_domains_operations.py @@ -0,0 +1,759 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, + service_name: str, + api_portal_name: str, + domain_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, + service_name: str, + api_portal_name: str, + domain_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( + resource_group_name: str, service_name: str, api_portal_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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 ApiPortalCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`api_portal_custom_domains` 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, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any + ) -> _models.ApiPortalCustomDomainResource: + """Get the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiPortalCustomDomainResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], + **kwargs: Any + ) -> _models.ApiPortalCustomDomainResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_custom_domain_resource, (IO, bytes)): + _content = api_portal_custom_domain_resource + else: + _json = self._serialize.body(api_portal_custom_domain_resource, "ApiPortalCustomDomainResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: _models.ApiPortalCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], + **kwargs: Any + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Is either a model type or a IO type. Required. + :type api_portal_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + 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, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_name, + api_portal_custom_domain_resource=api_portal_custom_domain_resource, + 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("ApiPortalCustomDomainResource", 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> Iterable["_models.ApiPortalCustomDomainResource"]: + """Handle requests to list all API portal custom domains. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiPortalCustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalCustomDomainResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResourceCollection] + + 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, + service_name=service_name, + api_portal_name=api_portal_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiPortalCustomDomainResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_api_portals_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_api_portals_operations.py new file mode 100644 index 000000000000..bfd35201a763 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_api_portals_operations.py @@ -0,0 +1,900 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_name: str, api_portal_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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, service_name: str, api_portal_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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, service_name: str, api_portal_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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_request(resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_domain_request( + resource_group_name: str, service_name: str, api_portal_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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 ApiPortalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`api_portals` 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, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> _models.ApiPortalResource: + """Get the API portal and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiPortalResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiPortalResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: Union[_models.ApiPortalResource, IO], + **kwargs: Any + ) -> _models.ApiPortalResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_resource, (IO, bytes)): + _content = api_portal_resource + else: + _json = self._serialize.body(api_portal_resource, "ApiPortalResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApiPortalResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApiPortalResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: _models.ApiPortalResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: Union[_models.ApiPortalResource, IO], + **kwargs: Any + ) -> LROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Is either a + model type or a IO type. Required. + :type api_portal_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + 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, + service_name=service_name, + api_portal_name=api_portal_name, + api_portal_resource=api_portal_resource, + 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("ApiPortalResource", 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, api_portal_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the default API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + api_portal_name=api_portal_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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.ApiPortalResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiPortalResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.ApiPortalResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiPortalResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") + + request = build_validate_domain_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate_domain.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_apps_operations.py new file mode 100644 index 000000000000..ef5936949a0b --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_apps_operations.py @@ -0,0 +1,1572 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + app_name: str, + subscription_id: str, + *, + sync_status: 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if sync_status is not None: + _params["syncStatus"] = _SERIALIZER.query("sync_status", sync_status, "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, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 + 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, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_resource_upload_url_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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_set_active_deployments_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_domain_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 + 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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`apps` 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, + resource_group_name: str, + service_name: str, + app_name: str, + sync_status: Optional[str] = None, + **kwargs: Any + ) -> _models.AppResource: + """Get an App and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param sync_status: Indicates whether sync status. Default value is None. + :type sync_status: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AppResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + sync_status=sync_status, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> _models.AppResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, + service_name=service_name, + app_name=app_name, + app_resource=app_resource, + 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("AppResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Operation to delete an App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + app_name=app_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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> _models.AppResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + app_resource=app_resource, + 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("AppResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.AppResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AppResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AppResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + + @distributed_trace + def get_resource_upload_url( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: + """Get an resource upload URL for an App, which may be artifacts or source archive. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceUploadDefinition or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceUploadDefinition + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] + + request = build_get_resource_upload_url_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_resource_upload_url.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + + def _set_active_deployments_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], + **kwargs: Any + ) -> _models.AppResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(active_deployment_collection, (IO, bytes)): + _content = active_deployment_collection + else: + _json = self._serialize.body(active_deployment_collection, "ActiveDeploymentCollection") + + request = build_set_active_deployments_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._set_active_deployments_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _set_active_deployments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + + @overload + def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: _models.ActiveDeploymentCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ActiveDeploymentCollection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Is either a model + type or a IO type. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ActiveDeploymentCollection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.AppResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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._set_active_deployments_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + active_deployment_collection=active_deployment_collection, + 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("AppResource", 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_set_active_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") + + request = build_validate_domain_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate_domain.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_bindings_operations.py new file mode 100644 index 000000000000..a76afc517723 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_bindings_operations.py @@ -0,0 +1,1033 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_name: str, app_name: str, binding_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, service_name: str, app_name: str, binding_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, service_name: str, app_name: str, binding_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, service_name: str, app_name: str, binding_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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) + + +def build_list_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`bindings` 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, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: + """Get a Binding and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BindingResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> _models.BindingResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, + service_name=service_name, + app_name=app_name, + binding_name=binding_name, + binding_resource=binding_resource, + 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("BindingResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, binding_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Operation to delete a Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + app_name=app_name, + binding_name=binding_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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> _models.BindingResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_name, + binding_resource=binding_resource, + 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("BindingResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.BindingResource"]: + """Handles requests to list all resources in an App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type 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 BindingResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.BindingResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] + + 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, + service_name=service_name, + app_name=app_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BindingResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_build_service_agent_pool_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_build_service_agent_pool_operations.py new file mode 100644 index 000000000000..d5b983fa8b45 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_build_service_agent_pool_operations.py @@ -0,0 +1,597 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, service_name: str, build_service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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, + service_name: str, + build_service_name: str, + agent_pool_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_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_update_put_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_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) + + +class BuildServiceAgentPoolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`build_service_agent_pool` 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, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.BuildServiceAgentPoolResource"]: + """List build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildServiceAgentPoolResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResourceCollection] + + 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, + service_name=service_name, + build_service_name=build_service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BuildServiceAgentPoolResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: + """Get build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildServiceAgentPoolResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + agent_pool_name=agent_pool_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + + def _update_put_initial( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], + **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(agent_pool_resource, (IO, bytes)): + _content = agent_pool_resource + else: + _json = self._serialize.body(agent_pool_resource, "BuildServiceAgentPoolResource") + + request = build_update_put_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_put_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: _models.BuildServiceAgentPoolResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildServiceAgentPoolResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + 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_put_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + agent_pool_name=agent_pool_name, + agent_pool_resource=agent_pool_resource, + 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("BuildServiceAgentPoolResource", 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_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_build_service_builder_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_build_service_builder_operations.py new file mode 100644 index 000000000000..a5abf7f3e191 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_build_service_builder_operations.py @@ -0,0 +1,864 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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, + service_name: str, + build_service_name: str, + builder_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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, + service_name: str, + build_service_name: str, + builder_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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_request( + resource_group_name: str, service_name: str, build_service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_deployments_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/listUsingDeployments", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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 BuildServiceBuilderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`build_service_builder` 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, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.BuilderResource: + """Get a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuilderResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuilderResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: Union[_models.BuilderResource, IO], + **kwargs: Any + ) -> _models.BuilderResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(builder_resource, (IO, bytes)): + _content = builder_resource + else: + _json = self._serialize.body(builder_resource, "BuilderResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BuilderResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BuilderResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: _models.BuilderResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: Union[_models.BuilderResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Is either a + model type or a IO type. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + builder_resource=builder_resource, + 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("BuilderResource", 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, build_service_name: str, builder_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.BuilderResource"]: + """List KPack builders result. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuilderResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuilderResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResourceCollection] + + 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, + service_name=service_name, + build_service_name=build_service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BuilderResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore + + @distributed_trace + def list_deployments( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.DeploymentList: + """List deployments that are using the builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentList or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentList + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentList] + + request = build_list_deployments_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_deployments.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeploymentList", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/listUsingDeployments"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_build_service_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_build_service_operations.py new file mode 100644 index 000000000000..1f8728ad2562 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_build_service_operations.py @@ -0,0 +1,1624 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_build_services_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_build_service_request( + resource_group_name: str, service_name: str, build_service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_builds_request( + resource_group_name: str, service_name: str, build_service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_build_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_build_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_list_build_results_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_build_result_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build_result_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_name, "str"), + "buildResultName": _SERIALIZER.url("build_result_name", build_result_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_build_result_log_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build_result_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_name, "str"), + "buildResultName": _SERIALIZER.url("build_result_name", build_result_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_resource_upload_url_request( + resource_group_name: str, service_name: str, build_service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_list_supported_buildpacks_request( + resource_group_name: str, service_name: str, build_service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_supported_buildpack_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + buildpack_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildpackName": _SERIALIZER.url("buildpack_name", buildpack_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_supported_stacks_request( + resource_group_name: str, service_name: str, build_service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_supported_stack_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + stack_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "stackName": _SERIALIZER.url("stack_name", stack_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 BuildServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`build_service` 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_build_services( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.BuildService"]: + """List build services resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildService or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildService] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceCollection] + + 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_build_services_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_build_services.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BuildServiceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_build_services.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore + + @distributed_trace + def get_build_service( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.BuildService: + """Get a build service resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildService or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildService + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildService] + + request = build_get_build_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build_service.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildService", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore + + @distributed_trace + def list_builds( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.Build"]: + """List KPack builds. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Build or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.Build] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildCollection] + + 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_builds_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_builds.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BuildCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_builds.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore + + @distributed_trace + def get_build( + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> _models.Build: + """Get a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Build + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] + + request = build_get_build_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Build", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + + @overload + def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: _models.Build, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Build + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: Union[_models.Build, IO], + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type build: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Build or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.Build + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build, (IO, bytes)): + _content = build + else: + _json = self._serialize.body(build, "Build") + + request = build_create_or_update_build_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_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_build.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Build", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Build", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + + @distributed_trace + def list_build_results( + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> Iterable["_models.BuildResult"]: + """List KPack build results. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildResult] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultCollection] + + 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_build_results_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_build_results.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BuildResultCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_build_results.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore + + @distributed_trace + def get_build_result( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build_result_name: str, + **kwargs: Any + ) -> _models.BuildResult: + """Get a KPack build result. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build_result_name: The name of the build result resource. Required. + :type build_result_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildResult + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResult] + + request = build_get_build_result_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + build_result_name=build_result_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build_result.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore + + @distributed_trace + def get_build_result_log( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build_result_name: str, + **kwargs: Any + ) -> _models.BuildResultLog: + """Get a KPack build result log download URL. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build_result_name: The name of the build result resource. Required. + :type build_result_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildResultLog or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildResultLog + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultLog] + + request = build_get_build_result_log_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + build_result_name=build_result_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build_result_log.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildResultLog", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build_result_log.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore + + @distributed_trace + def get_resource_upload_url( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: + """Get an resource upload URL for build service, which may be artifacts or source archive. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceUploadDefinition or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceUploadDefinition + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] + + request = build_get_resource_upload_url_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_resource_upload_url.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore + + @distributed_trace + def list_supported_buildpacks( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedBuildpacksCollection: + """Get all supported buildpacks. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedBuildpacksCollection or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedBuildpacksCollection + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpacksCollection] + + request = build_list_supported_buildpacks_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_supported_buildpacks.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedBuildpacksCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_supported_buildpacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore + + @distributed_trace + def get_supported_buildpack( + self, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, **kwargs: Any + ) -> _models.SupportedBuildpackResource: + """Get the supported buildpack resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param buildpack_name: The name of the buildpack resource. Required. + :type buildpack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedBuildpackResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedBuildpackResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpackResource] + + request = build_get_supported_buildpack_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + buildpack_name=buildpack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_supported_buildpack.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedBuildpackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_supported_buildpack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore + + @distributed_trace + def list_supported_stacks( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedStacksCollection: + """Get all supported stacks. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedStacksCollection or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedStacksCollection + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStacksCollection] + + request = build_list_supported_stacks_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_supported_stacks.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedStacksCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_supported_stacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore + + @distributed_trace + def get_supported_stack( + self, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, **kwargs: Any + ) -> _models.SupportedStackResource: + """Get the supported stack resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param stack_name: The name of the stack resource. Required. + :type stack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedStackResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.SupportedStackResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStackResource] + + request = build_get_supported_stack_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + stack_name=stack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_supported_stack.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedStackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_supported_stack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_buildpack_binding_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_buildpack_binding_operations.py new file mode 100644 index 000000000000..480b1a330839 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_buildpack_binding_operations.py @@ -0,0 +1,811 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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 BuildpackBindingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`buildpack_binding` 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, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + **kwargs: Any + ) -> _models.BuildpackBindingResource: + """Get a buildpack binding by name. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildpackBindingResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> _models.BuildpackBindingResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(buildpack_binding, (IO, bytes)): + _content = buildpack_binding + else: + _json = self._serialize.body(buildpack_binding, "BuildpackBindingResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: _models.BuildpackBindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. Is + either a model type or a IO type. Required. + :type buildpack_binding: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_name, + buildpack_binding=buildpack_binding, + 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("BuildpackBindingResource", 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Operation to delete a Buildpack Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> Iterable["_models.BuildpackBindingResource"]: + """Handles requests to list all buildpack bindings in a builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.BuildpackBindingResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResourceCollection] + + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BuildpackBindingResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_certificates_operations.py new file mode 100644 index 000000000000..c064e756ee0b --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_certificates_operations.py @@ -0,0 +1,716 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_list_request(resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`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 get( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: + """Get the certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: Union[_models.CertificateResource, IO], + **kwargs: Any + ) -> _models.CertificateResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_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_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: Union[_models.CertificateResource, IO], + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, + service_name=service_name, + certificate_name=certificate_name, + certificate_resource=certificate_resource, + 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("CertificateResource", 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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, certificate_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + certificate_name=certificate_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + certificate_name=certificate_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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.CertificateResource"]: + """List all the certificates of one user. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CertificateResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.CertificateResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CertificateResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_config_servers_operations.py new file mode 100644 index 000000000000..d9d3d89558ff --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_config_servers_operations.py @@ -0,0 +1,950 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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) + + +def build_validate_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/validate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`config_servers` 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, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: + """Get the config server and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigServerResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + def _update_put_initial( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> _models.ConfigServerResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_put_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + config_server_resource=config_server_resource, + 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("ConfigServerResource", 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_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + def _update_patch_initial( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> _models.ConfigServerResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_patch_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + config_server_resource=config_server_resource, + 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("ConfigServerResource", 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_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + def _validate_initial( + self, + resource_group_name: str, + service_name: str, + config_server_settings: Union[_models.ConfigServerSettings, IO], + **kwargs: Any + ) -> _models.ConfigServerSettingsValidateResult: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._validate_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: Union[_models.ConfigServerSettings, IO], + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigServerSettingsValidateResult] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + config_server_settings=config_server_settings, + 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("ConfigServerSettingsValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_configuration_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_configuration_services_operations.py new file mode 100644 index 000000000000..a1873a3c6fe4 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_configuration_services_operations.py @@ -0,0 +1,996 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_name: str, configuration_service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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, service_name: str, configuration_service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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, service_name: str, configuration_service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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_request(resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_request( + resource_group_name: str, service_name: str, configuration_service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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 ConfigurationServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`configuration_services` 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, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> _models.ConfigurationServiceResource: + """Get the Application Configuration Service and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationServiceResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], + **kwargs: Any + ) -> _models.ConfigurationServiceResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_service_resource, (IO, bytes)): + _content = configuration_service_resource + else: + _json = self._serialize.body(configuration_service_resource, "ConfigurationServiceResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: _models.ConfigurationServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Is either a model + type or a IO type. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + 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, + service_name=service_name, + configuration_service_name=configuration_service_name, + configuration_service_resource=configuration_service_resource, + 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("ConfigurationServiceResource", 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, configuration_service_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Disable the default Application Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + configuration_service_name=configuration_service_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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.ConfigurationServiceResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConfigurationServiceResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConfigurationServiceResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore + + def _validate_initial( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: Union[_models.ConfigurationServiceSettings, IO], + **kwargs: Any + ) -> _models.ConfigurationServiceSettingsValidateResult: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(settings, (IO, bytes)): + _content = settings + else: + _json = self._serialize.body(settings, "ConfigurationServiceSettings") + + request = build_validate_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._validate_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: _models.ConfigurationServiceSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: Union[_models.ConfigurationServiceSettings, IO], + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Is either a model + type or a IO type. Required. + :type settings: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceSettings + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ConfigurationServiceSettingsValidateResult] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + 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._validate_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_name, + settings=settings, + 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("ConfigurationServiceSettingsValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_custom_domains_operations.py new file mode 100644 index 000000000000..9d6f3e6ff371 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_custom_domains_operations.py @@ -0,0 +1,1034 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_name: str, app_name: str, domain_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, service_name: str, app_name: str, domain_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, service_name: str, app_name: str, domain_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, service_name: str, app_name: str, domain_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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) + + +def build_list_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`custom_domains` 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, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: + """Get the custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CustomDomainResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> _models.CustomDomainResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, + service_name=service_name, + app_name=app_name, + domain_name=domain_name, + domain_resource=domain_resource, + 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("CustomDomainResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, domain_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + app_name=app_name, + domain_name=domain_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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> _models.CustomDomainResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_name, + domain_resource=domain_resource, + 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("CustomDomainResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.CustomDomainResource"]: + """List the custom domains of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type 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 CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] + + 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, + service_name=service_name, + app_name=app_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CustomDomainResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_deployments_operations.py new file mode 100644 index 000000000000..e40f842c64b3 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_deployments_operations.py @@ -0,0 +1,3216 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, + service_name: str, + app_name: str, + deployment_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, + service_name: str, + app_name: str, + deployment_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, + service_name: str, + app_name: str, + deployment_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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) + + +def build_list_request( + resource_group_name: str, + service_name: str, + app_name: str, + subscription_id: str, + *, + version: Optional[List[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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if version is not None: + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_for_cluster_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + version: Optional[List[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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if version is not None: + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_stop_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_restart_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_enable_remote_debugging_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/enableRemoteDebugging", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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) + + +def build_disable_remote_debugging_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/disableRemoteDebugging", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_remote_debugging_config_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getRemoteDebuggingConfig", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_log_file_url_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_generate_heap_dump_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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) + + +def build_generate_thread_dump_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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) + + +def build_start_jfr_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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 DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`deployments` 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, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: + """Get a Deployment and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> _models.DeploymentResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + deployment_resource=deployment_resource, + 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("DeploymentResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Operation to delete a Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> _models.DeploymentResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + deployment_resource=deployment_resource, + 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("DeploymentResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + app_name: str, + version: Optional[List[str]] = None, + **kwargs: Any + ) -> Iterable["_models.DeploymentResource"]: + """Handles requests to list all resources in an App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param version: Version of the deployments to be listed. Default value is None. + :type version: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] + + 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, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + version=version, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeploymentResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + + @distributed_trace + def list_for_cluster( + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentResource"]: + """List deployments for a certain service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param version: Version of the deployments to be listed. Default value is None. + :type version: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.DeploymentResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] + + 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_for_cluster_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + version=version, + api_version=api_version, + template_url=self.list_for_cluster.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeploymentResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + + def _start_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._start_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + + @distributed_trace + def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Start the deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._start_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + + def _stop_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._stop_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + + @distributed_trace + def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Stop the deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._stop_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + + def _restart_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._restart_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + + @distributed_trace + def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Restart the deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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._restart_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + + def _enable_remote_debugging_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[Union[_models.RemoteDebuggingPayload, IO]] = None, + **kwargs: Any + ) -> _models.RemoteDebugging: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(remote_debugging_payload, (IO, bytes)): + _content = remote_debugging_payload + else: + if remote_debugging_payload is not None: + _json = self._serialize.body(remote_debugging_payload, "RemoteDebuggingPayload") + else: + _json = None + + request = build_enable_remote_debugging_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._enable_remote_debugging_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _enable_remote_debugging_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/enableRemoteDebugging"} # type: ignore + + @overload + def begin_enable_remote_debugging( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[_models.RemoteDebuggingPayload] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RemoteDebugging]: + """Enable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param remote_debugging_payload: Parameters for enable remote debugging. Default value is None. + :type remote_debugging_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.RemoteDebuggingPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.RemoteDebugging] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_enable_remote_debugging( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RemoteDebugging]: + """Enable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param remote_debugging_payload: Parameters for enable remote debugging. Default value is None. + :type remote_debugging_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.RemoteDebugging] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_enable_remote_debugging( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[Union[_models.RemoteDebuggingPayload, IO]] = None, + **kwargs: Any + ) -> LROPoller[_models.RemoteDebugging]: + """Enable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param remote_debugging_payload: Parameters for enable remote debugging. Is either a model type + or a IO type. Default value is None. + :type remote_debugging_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.RemoteDebuggingPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.RemoteDebugging] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + 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._enable_remote_debugging_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + remote_debugging_payload=remote_debugging_payload, + 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("RemoteDebugging", 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_enable_remote_debugging.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/enableRemoteDebugging"} # type: ignore + + def _disable_remote_debugging_initial( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.RemoteDebugging: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + + request = build_disable_remote_debugging_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._disable_remote_debugging_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _disable_remote_debugging_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/disableRemoteDebugging"} # type: ignore + + @distributed_trace + def begin_disable_remote_debugging( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> LROPoller[_models.RemoteDebugging]: + """Disable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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 RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.RemoteDebugging] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + 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._disable_remote_debugging_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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): + deserialized = self._deserialize("RemoteDebugging", 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_disable_remote_debugging.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/disableRemoteDebugging"} # type: ignore + + @distributed_trace + def get_remote_debugging_config( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.RemoteDebugging: + """Get remote debugging config. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RemoteDebugging or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.RemoteDebugging + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + + request = build_get_remote_debugging_config_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_remote_debugging_config.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_remote_debugging_config.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getRemoteDebuggingConfig"} # type: ignore + + @distributed_trace + def get_log_file_url( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: + """Get deployment log file URL. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogFileUrlResponse or None or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.LogFileUrlResponse or 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] + + request = build_get_log_file_url_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_log_file_url.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore + + def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_heap_dump_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._generate_heap_dump_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _generate_heap_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + + @overload + def begin_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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._generate_heap_dump_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + diagnostic_parameters=diagnostic_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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_generate_heap_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + + def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_thread_dump_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._generate_thread_dump_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _generate_thread_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + @overload + def begin_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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._generate_thread_dump_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + diagnostic_parameters=diagnostic_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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_generate_thread_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + def _start_jfr_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_start_jfr_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._start_jfr_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_jfr_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + + @overload + def begin_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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._start_jfr_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + diagnostic_parameters=diagnostic_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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_start_jfr.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_gateway_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_gateway_custom_domains_operations.py new file mode 100644 index 000000000000..9a97ecdc5f9b --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_gateway_custom_domains_operations.py @@ -0,0 +1,759 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, + service_name: str, + gateway_name: str, + domain_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, + service_name: str, + gateway_name: str, + domain_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( + resource_group_name: str, service_name: str, gateway_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewayCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`gateway_custom_domains` 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, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any + ) -> _models.GatewayCustomDomainResource: + """Get the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayCustomDomainResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], + **kwargs: Any + ) -> _models.GatewayCustomDomainResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_custom_domain_resource, (IO, bytes)): + _content = gateway_custom_domain_resource + else: + _json = self._serialize.body(gateway_custom_domain_resource, "GatewayCustomDomainResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: _models.GatewayCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayCustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayCustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], + **kwargs: Any + ) -> LROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Is either a model type or a IO type. Required. + :type gateway_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayCustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + 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, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_name, + gateway_custom_domain_resource=gateway_custom_domain_resource, + 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("GatewayCustomDomainResource", 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, gateway_name: str, domain_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> Iterable["_models.GatewayCustomDomainResource"]: + """Handle requests to list all Spring Cloud Gateway custom domains. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayCustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayCustomDomainResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResourceCollection] + + 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, + service_name=service_name, + gateway_name=gateway_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GatewayCustomDomainResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_gateway_route_configs_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_gateway_route_configs_operations.py new file mode 100644 index 000000000000..ad3b32e3f268 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_gateway_route_configs_operations.py @@ -0,0 +1,762 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_config_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, + service_name: str, + gateway_name: str, + route_config_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_config_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, + service_name: str, + gateway_name: str, + route_config_name: str, + 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_config_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_request( + resource_group_name: str, service_name: str, gateway_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewayRouteConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`gateway_route_configs` 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, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any + ) -> _models.GatewayRouteConfigResource: + """Get the Spring Cloud Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayRouteConfigResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], + **kwargs: Any + ) -> _models.GatewayRouteConfigResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_route_config_resource, (IO, bytes)): + _content = gateway_route_config_resource + else: + _json = self._serialize.body(gateway_route_config_resource, "GatewayRouteConfigResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: _models.GatewayRouteConfigResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayRouteConfigResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayRouteConfigResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], + **kwargs: Any + ) -> LROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Is either a model type or a IO type. Required. + :type gateway_route_config_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayRouteConfigResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + 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, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_name, + gateway_route_config_resource=gateway_route_config_resource, + 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("GatewayRouteConfigResource", 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the Spring Cloud Gateway route config. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> Iterable["_models.GatewayRouteConfigResource"]: + """Handle requests to list all Spring Cloud Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayRouteConfigResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayRouteConfigResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResourceCollection] + + 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, + service_name=service_name, + gateway_name=gateway_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GatewayRouteConfigResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_gateways_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_gateways_operations.py new file mode 100644 index 000000000000..dd23c6f55574 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_gateways_operations.py @@ -0,0 +1,900 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_name: str, gateway_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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, service_name: str, gateway_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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, service_name: str, gateway_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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_request(resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_domain_request( + resource_group_name: str, service_name: str, gateway_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewaysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`gateways` 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, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> _models.GatewayResource: + """Get the Spring Cloud Gateway and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GatewayResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: Union[_models.GatewayResource, IO], + **kwargs: Any + ) -> _models.GatewayResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_resource, (IO, bytes)): + _content = gateway_resource + else: + _json = self._serialize.body(gateway_resource, "GatewayResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GatewayResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GatewayResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: _models.GatewayResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: Union[_models.GatewayResource, IO], + **kwargs: Any + ) -> LROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Is either a model type + or a IO type. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + 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, + service_name=service_name, + gateway_name=gateway_name, + gateway_resource=gateway_resource, + 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("GatewayResource", 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, gateway_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Disable the default Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + gateway_name=gateway_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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.GatewayResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.GatewayResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GatewayResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.CustomDomainValidateResult + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") + + request = build_validate_domain_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate_domain.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_monitoring_settings_operations.py new file mode 100644 index 000000000000..1a1aaf031fe4 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_monitoring_settings_operations.py @@ -0,0 +1,683 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`monitoring_settings` 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, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.MonitoringSettingResource: + """Get the Monitoring Setting and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + def _update_put_initial( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> _models.MonitoringSettingResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_put_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + monitoring_setting_resource=monitoring_setting_resource, + 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("MonitoringSettingResource", 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_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + def _update_patch_initial( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> _models.MonitoringSettingResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_patch_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.MonitoringSettingResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + monitoring_setting_resource=monitoring_setting_resource, + 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("MonitoringSettingResource", 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_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_operations.py new file mode 100644 index 000000000000..6b5d7b0bdc53 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_operations.py @@ -0,0 +1,163 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/operations") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.OperationDetail"]: + """Lists all of the available REST API operations of the Microsoft.AppPlatform provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationDetail or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.OperationDetail] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableOperations] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AvailableOperations", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_runtime_versions_operations.py new file mode 100644 index 000000000000..f315ea527a7a --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_runtime_versions_operations.py @@ -0,0 +1,133 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, 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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_runtime_versions_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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/runtimeVersions") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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 RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`runtime_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: + """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AvailableRuntimeVersions or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.AvailableRuntimeVersions + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] + + request = build_list_runtime_versions_request( + api_version=api_version, + template_url=self.list_runtime_versions.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_service_registries_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_service_registries_operations.py new file mode 100644 index 000000000000..d09b5764c487 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_service_registries_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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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_request(resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ServiceRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`service_registries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: + """Get the Service Registry and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param service_registry_name: The name of Service Registry. Required. + :type service_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServiceRegistryResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceRegistryResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + def _create_or_update_initial( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> LROPoller[_models.ServiceRegistryResource]: + """Create the default Service Registry or update the existing Service Registry. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param service_registry_name: The name of Service Registry. Required. + :type service_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceRegistryResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceRegistryResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + 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, + service_name=service_name, + service_registry_name=service_registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ServiceRegistryResource", 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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Disable the default Service Registry. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param service_registry_name: The name of Service Registry. Required. + :type service_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + service_registry_name=service_registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.ServiceRegistryResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServiceRegistryResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceRegistryResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceRegistryResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_services_operations.py new file mode 100644 index 000000000000..8772cfe1b84c --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_services_operations.py @@ -0,0 +1,1933 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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) + + +def build_list_test_keys_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_regenerate_test_key_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/regenerateTestKey", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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) + + +def build_disable_test_endpoint_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_enable_test_endpoint_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_stop_request(resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_start_request( + resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_check_name_availability_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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "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) + + +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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`services` 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, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: + """Get a Service and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServiceResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + def _create_or_update_initial( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + resource: _models.ServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, + service_name=service_name, + resource=resource, + 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("ServiceResource", 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.AppPlatform/Spring/{serviceName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: + """Operation to delete a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_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.AppPlatform/Spring/{serviceName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: _models.ServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + resource=resource, + 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("ServiceResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @distributed_trace + def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: + """List test keys for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.TestKeys + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + request = build_list_test_keys_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_test_keys.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.TestKeys + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") + + request = build_regenerate_test_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.regenerate_test_key.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore + + @distributed_trace + def disable_test_endpoint( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + """Disable test endpoint functionality for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_disable_test_endpoint_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.disable_test_endpoint.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore + + @distributed_trace + def enable_test_endpoint(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: + """Enable test endpoint functionality for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.TestKeys + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + request = build_enable_test_endpoint_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.enable_test_endpoint.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore + + def _stop_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._stop_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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + + @distributed_trace + def begin_stop(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: + """Stop a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._stop_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_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_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + + def _start_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._start_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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + + @distributed_trace + def begin_start(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: + """Start a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._start_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_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_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + + @overload + def check_name_availability( + self, + location: str, + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_09_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.NameAvailability + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") + + request = build_check_name_availability_request( + location=location, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NameAvailability", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ServiceResource"]: + """Handles requests to list all resources in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServiceResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] + + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceResourceList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ServiceResource"]: + """Handles requests to list all resources in a resource group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.ServiceResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] + + 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, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceResourceList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_skus_operations.py new file mode 100644 index 000000000000..7aef3b60d09d --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_skus_operations.py @@ -0,0 +1,169 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`skus` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.ResourceSku"]: + """Lists all of the available skus of the Microsoft.AppPlatform provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceSku or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.ResourceSku] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceSkuCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_storages_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_storages_operations.py new file mode 100644 index 000000000000..262b135172c4 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/operations/_storages_operations.py @@ -0,0 +1,713 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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) + + +def build_list_request(resource_group_name: str, service_name: str, 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-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 StoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_09_01_preview.AppPlatformManagementClient`'s + :attr:`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 get( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> _models.StorageResource: + """Get the storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: Union[_models.StorageResource, IO], + **kwargs: Any + ) -> _models.StorageResource: + 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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_resource, (IO, bytes)): + _content = storage_resource + else: + _json = self._serialize.body(storage_resource, "StorageResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_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_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("StorageResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("StorageResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("StorageResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: _models.StorageResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: Union[_models.StorageResource, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + 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, + service_name=service_name, + storage_name=storage_name, + storage_resource=storage_resource, + 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("StorageResource", 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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, storage_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + storage_name=storage_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + 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, + service_name=service_name, + storage_name=storage_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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.StorageResource"]: + """List all the storages of one Azure Spring Apps resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StorageResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_09_01_preview.models.StorageResource] + :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", "2022-09-01-preview") + ) # type: Literal["2022-09-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/py.typed b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_09_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/__init__.py new file mode 100644 index 000000000000..a6bfaa2de14d --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/__init__.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._app_platform_management_client import AppPlatformManagementClient +from ._version import VERSION + +__version__ = VERSION + +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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_app_platform_management_client.py new file mode 100644 index 000000000000..d39c2495abbd --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_app_platform_management_client.py @@ -0,0 +1,254 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from .._serialization import Deserializer, Serializer +from ._configuration import AppPlatformManagementClientConfiguration +from .operations import ( + ApiPortalCustomDomainsOperations, + ApiPortalsOperations, + ApplicationAcceleratorsOperations, + ApplicationLiveViewsOperations, + AppsOperations, + BindingsOperations, + BuildServiceAgentPoolOperations, + BuildServiceBuilderOperations, + BuildServiceOperations, + BuildpackBindingOperations, + CertificatesOperations, + ConfigServersOperations, + ConfigurationServicesOperations, + CustomDomainsOperations, + CustomizedAcceleratorsOperations, + DeploymentsOperations, + DevToolPortalsOperations, + GatewayCustomDomainsOperations, + GatewayRouteConfigsOperations, + GatewaysOperations, + MonitoringSettingsOperations, + Operations, + PredefinedAcceleratorsOperations, + RuntimeVersionsOperations, + ServiceRegistriesOperations, + ServicesOperations, + SkusOperations, + StoragesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """REST API for Azure Spring Apps. + + :ivar services: ServicesOperations operations + :vartype services: azure.mgmt.appplatform.v2022_11_01_preview.operations.ServicesOperations + :ivar config_servers: ConfigServersOperations operations + :vartype config_servers: + azure.mgmt.appplatform.v2022_11_01_preview.operations.ConfigServersOperations + :ivar configuration_services: ConfigurationServicesOperations operations + :vartype configuration_services: + azure.mgmt.appplatform.v2022_11_01_preview.operations.ConfigurationServicesOperations + :ivar service_registries: ServiceRegistriesOperations operations + :vartype service_registries: + azure.mgmt.appplatform.v2022_11_01_preview.operations.ServiceRegistriesOperations + :ivar application_live_views: ApplicationLiveViewsOperations operations + :vartype application_live_views: + azure.mgmt.appplatform.v2022_11_01_preview.operations.ApplicationLiveViewsOperations + :ivar dev_tool_portals: DevToolPortalsOperations operations + :vartype dev_tool_portals: + azure.mgmt.appplatform.v2022_11_01_preview.operations.DevToolPortalsOperations + :ivar build_service: BuildServiceOperations operations + :vartype build_service: + azure.mgmt.appplatform.v2022_11_01_preview.operations.BuildServiceOperations + :ivar buildpack_binding: BuildpackBindingOperations operations + :vartype buildpack_binding: + azure.mgmt.appplatform.v2022_11_01_preview.operations.BuildpackBindingOperations + :ivar build_service_builder: BuildServiceBuilderOperations operations + :vartype build_service_builder: + azure.mgmt.appplatform.v2022_11_01_preview.operations.BuildServiceBuilderOperations + :ivar build_service_agent_pool: BuildServiceAgentPoolOperations operations + :vartype build_service_agent_pool: + azure.mgmt.appplatform.v2022_11_01_preview.operations.BuildServiceAgentPoolOperations + :ivar monitoring_settings: MonitoringSettingsOperations operations + :vartype monitoring_settings: + azure.mgmt.appplatform.v2022_11_01_preview.operations.MonitoringSettingsOperations + :ivar apps: AppsOperations operations + :vartype apps: azure.mgmt.appplatform.v2022_11_01_preview.operations.AppsOperations + :ivar bindings: BindingsOperations operations + :vartype bindings: azure.mgmt.appplatform.v2022_11_01_preview.operations.BindingsOperations + :ivar storages: StoragesOperations operations + :vartype storages: azure.mgmt.appplatform.v2022_11_01_preview.operations.StoragesOperations + :ivar certificates: CertificatesOperations operations + :vartype certificates: + azure.mgmt.appplatform.v2022_11_01_preview.operations.CertificatesOperations + :ivar custom_domains: CustomDomainsOperations operations + :vartype custom_domains: + azure.mgmt.appplatform.v2022_11_01_preview.operations.CustomDomainsOperations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: + azure.mgmt.appplatform.v2022_11_01_preview.operations.DeploymentsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.appplatform.v2022_11_01_preview.operations.Operations + :ivar runtime_versions: RuntimeVersionsOperations operations + :vartype runtime_versions: + azure.mgmt.appplatform.v2022_11_01_preview.operations.RuntimeVersionsOperations + :ivar skus: SkusOperations operations + :vartype skus: azure.mgmt.appplatform.v2022_11_01_preview.operations.SkusOperations + :ivar gateways: GatewaysOperations operations + :vartype gateways: azure.mgmt.appplatform.v2022_11_01_preview.operations.GatewaysOperations + :ivar gateway_route_configs: GatewayRouteConfigsOperations operations + :vartype gateway_route_configs: + azure.mgmt.appplatform.v2022_11_01_preview.operations.GatewayRouteConfigsOperations + :ivar gateway_custom_domains: GatewayCustomDomainsOperations operations + :vartype gateway_custom_domains: + azure.mgmt.appplatform.v2022_11_01_preview.operations.GatewayCustomDomainsOperations + :ivar api_portals: ApiPortalsOperations operations + :vartype api_portals: + azure.mgmt.appplatform.v2022_11_01_preview.operations.ApiPortalsOperations + :ivar api_portal_custom_domains: ApiPortalCustomDomainsOperations operations + :vartype api_portal_custom_domains: + azure.mgmt.appplatform.v2022_11_01_preview.operations.ApiPortalCustomDomainsOperations + :ivar application_accelerators: ApplicationAcceleratorsOperations operations + :vartype application_accelerators: + azure.mgmt.appplatform.v2022_11_01_preview.operations.ApplicationAcceleratorsOperations + :ivar customized_accelerators: CustomizedAcceleratorsOperations operations + :vartype customized_accelerators: + azure.mgmt.appplatform.v2022_11_01_preview.operations.CustomizedAcceleratorsOperations + :ivar predefined_accelerators: PredefinedAcceleratorsOperations operations + :vartype predefined_accelerators: + azure.mgmt.appplatform.v2022_11_01_preview.operations.PredefinedAcceleratorsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. 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-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AppPlatformManagementClientConfiguration( + 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.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_services = ConfigurationServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_registries = ServiceRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_live_views = ApplicationLiveViewsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dev_tool_portals = DevToolPortalsOperations(self._client, self._config, self._serialize, self._deserialize) + self.build_service = BuildServiceOperations(self._client, self._config, self._serialize, self._deserialize) + self.buildpack_binding = BuildpackBindingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_builder = BuildServiceBuilderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_agent_pool = BuildServiceAgentPoolOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) + self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.storages = StoragesOperations(self._client, self._config, self._serialize, self._deserialize) + self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateways = GatewaysOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_route_configs = GatewayRouteConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gateway_custom_domains = GatewayCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_portals = ApiPortalsOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_portal_custom_domains = ApiPortalCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_accelerators = ApplicationAcceleratorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.customized_accelerators = CustomizedAcceleratorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.predefined_accelerators = PredefinedAcceleratorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AppPlatformManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_configuration.py new file mode 100644 index 000000000000..76f74a1d109e --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_configuration.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import sys +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class AppPlatformManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for AppPlatformManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-11-01-preview") # type: Literal["2022-11-01-preview"] + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_metadata.json b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_metadata.json new file mode 100644 index 000000000000..91ceb1d261d4 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_metadata.json @@ -0,0 +1,129 @@ +{ + "chosen_version": "2022-11-01-preview", + "total_api_version_list": ["2022-11-01-preview"], + "client": { + "name": "AppPlatformManagementClient", + "filename": "_app_platform_management_client", + "description": "REST API for Azure Spring Apps.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppPlatformManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Gets subscription ID which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", + "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: str = \"https://management.azure.com\",", + "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": { + "services": "ServicesOperations", + "config_servers": "ConfigServersOperations", + "configuration_services": "ConfigurationServicesOperations", + "service_registries": "ServiceRegistriesOperations", + "application_live_views": "ApplicationLiveViewsOperations", + "dev_tool_portals": "DevToolPortalsOperations", + "build_service": "BuildServiceOperations", + "buildpack_binding": "BuildpackBindingOperations", + "build_service_builder": "BuildServiceBuilderOperations", + "build_service_agent_pool": "BuildServiceAgentPoolOperations", + "monitoring_settings": "MonitoringSettingsOperations", + "apps": "AppsOperations", + "bindings": "BindingsOperations", + "storages": "StoragesOperations", + "certificates": "CertificatesOperations", + "custom_domains": "CustomDomainsOperations", + "deployments": "DeploymentsOperations", + "operations": "Operations", + "runtime_versions": "RuntimeVersionsOperations", + "skus": "SkusOperations", + "gateways": "GatewaysOperations", + "gateway_route_configs": "GatewayRouteConfigsOperations", + "gateway_custom_domains": "GatewayCustomDomainsOperations", + "api_portals": "ApiPortalsOperations", + "api_portal_custom_domains": "ApiPortalCustomDomainsOperations", + "application_accelerators": "ApplicationAcceleratorsOperations", + "customized_accelerators": "CustomizedAcceleratorsOperations", + "predefined_accelerators": "PredefinedAcceleratorsOperations" + } +} diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_vendor.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_version.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_version.py new file mode 100644 index 000000000000..92453d8691d9 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "6.1.0" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/__init__.py new file mode 100644 index 000000000000..398c48287ad8 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._app_platform_management_client import AppPlatformManagementClient + +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__ = [ + "AppPlatformManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/_app_platform_management_client.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/_app_platform_management_client.py new file mode 100644 index 000000000000..dcc91a5d4d22 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/_app_platform_management_client.py @@ -0,0 +1,251 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ..._serialization import Deserializer, Serializer +from ._configuration import AppPlatformManagementClientConfiguration +from .operations import ( + ApiPortalCustomDomainsOperations, + ApiPortalsOperations, + ApplicationAcceleratorsOperations, + ApplicationLiveViewsOperations, + AppsOperations, + BindingsOperations, + BuildServiceAgentPoolOperations, + BuildServiceBuilderOperations, + BuildServiceOperations, + BuildpackBindingOperations, + CertificatesOperations, + ConfigServersOperations, + ConfigurationServicesOperations, + CustomDomainsOperations, + CustomizedAcceleratorsOperations, + DeploymentsOperations, + DevToolPortalsOperations, + GatewayCustomDomainsOperations, + GatewayRouteConfigsOperations, + GatewaysOperations, + MonitoringSettingsOperations, + Operations, + PredefinedAcceleratorsOperations, + RuntimeVersionsOperations, + ServiceRegistriesOperations, + ServicesOperations, + SkusOperations, + StoragesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AppPlatformManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """REST API for Azure Spring Apps. + + :ivar services: ServicesOperations operations + :vartype services: azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.ServicesOperations + :ivar config_servers: ConfigServersOperations operations + :vartype config_servers: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.ConfigServersOperations + :ivar configuration_services: ConfigurationServicesOperations operations + :vartype configuration_services: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.ConfigurationServicesOperations + :ivar service_registries: ServiceRegistriesOperations operations + :vartype service_registries: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.ServiceRegistriesOperations + :ivar application_live_views: ApplicationLiveViewsOperations operations + :vartype application_live_views: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.ApplicationLiveViewsOperations + :ivar dev_tool_portals: DevToolPortalsOperations operations + :vartype dev_tool_portals: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.DevToolPortalsOperations + :ivar build_service: BuildServiceOperations operations + :vartype build_service: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.BuildServiceOperations + :ivar buildpack_binding: BuildpackBindingOperations operations + :vartype buildpack_binding: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.BuildpackBindingOperations + :ivar build_service_builder: BuildServiceBuilderOperations operations + :vartype build_service_builder: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.BuildServiceBuilderOperations + :ivar build_service_agent_pool: BuildServiceAgentPoolOperations operations + :vartype build_service_agent_pool: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.BuildServiceAgentPoolOperations + :ivar monitoring_settings: MonitoringSettingsOperations operations + :vartype monitoring_settings: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.MonitoringSettingsOperations + :ivar apps: AppsOperations operations + :vartype apps: azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.AppsOperations + :ivar bindings: BindingsOperations operations + :vartype bindings: azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.BindingsOperations + :ivar storages: StoragesOperations operations + :vartype storages: azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.StoragesOperations + :ivar certificates: CertificatesOperations operations + :vartype certificates: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.CertificatesOperations + :ivar custom_domains: CustomDomainsOperations operations + :vartype custom_domains: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.CustomDomainsOperations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.DeploymentsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.Operations + :ivar runtime_versions: RuntimeVersionsOperations operations + :vartype runtime_versions: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.RuntimeVersionsOperations + :ivar skus: SkusOperations operations + :vartype skus: azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.SkusOperations + :ivar gateways: GatewaysOperations operations + :vartype gateways: azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.GatewaysOperations + :ivar gateway_route_configs: GatewayRouteConfigsOperations operations + :vartype gateway_route_configs: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.GatewayRouteConfigsOperations + :ivar gateway_custom_domains: GatewayCustomDomainsOperations operations + :vartype gateway_custom_domains: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.GatewayCustomDomainsOperations + :ivar api_portals: ApiPortalsOperations operations + :vartype api_portals: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.ApiPortalsOperations + :ivar api_portal_custom_domains: ApiPortalCustomDomainsOperations operations + :vartype api_portal_custom_domains: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.ApiPortalCustomDomainsOperations + :ivar application_accelerators: ApplicationAcceleratorsOperations operations + :vartype application_accelerators: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.ApplicationAcceleratorsOperations + :ivar customized_accelerators: CustomizedAcceleratorsOperations operations + :vartype customized_accelerators: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.CustomizedAcceleratorsOperations + :ivar predefined_accelerators: PredefinedAcceleratorsOperations operations + :vartype predefined_accelerators: + azure.mgmt.appplatform.v2022_11_01_preview.aio.operations.PredefinedAcceleratorsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. 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-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AppPlatformManagementClientConfiguration( + 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.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.config_servers = ConfigServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_services = ConfigurationServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_registries = ServiceRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_live_views = ApplicationLiveViewsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dev_tool_portals = DevToolPortalsOperations(self._client, self._config, self._serialize, self._deserialize) + self.build_service = BuildServiceOperations(self._client, self._config, self._serialize, self._deserialize) + self.buildpack_binding = BuildpackBindingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_builder = BuildServiceBuilderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.build_service_agent_pool = BuildServiceAgentPoolOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.monitoring_settings = MonitoringSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.apps = AppsOperations(self._client, self._config, self._serialize, self._deserialize) + self.bindings = BindingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.storages = StoragesOperations(self._client, self._config, self._serialize, self._deserialize) + self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.runtime_versions = RuntimeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateways = GatewaysOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_route_configs = GatewayRouteConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gateway_custom_domains = GatewayCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_portals = ApiPortalsOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_portal_custom_domains = ApiPortalCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_accelerators = ApplicationAcceleratorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.customized_accelerators = CustomizedAcceleratorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.predefined_accelerators = PredefinedAcceleratorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AppPlatformManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/_configuration.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..e326c1b6e274 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/_configuration.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import sys +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AppPlatformManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for AppPlatformManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Gets subscription ID which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(AppPlatformManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-11-01-preview") # type: Literal["2022-11-01-preview"] + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appplatform/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..34185c849b5b --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/__init__.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._services_operations import ServicesOperations +from ._config_servers_operations import ConfigServersOperations +from ._configuration_services_operations import ConfigurationServicesOperations +from ._service_registries_operations import ServiceRegistriesOperations +from ._application_live_views_operations import ApplicationLiveViewsOperations +from ._dev_tool_portals_operations import DevToolPortalsOperations +from ._build_service_operations import BuildServiceOperations +from ._buildpack_binding_operations import BuildpackBindingOperations +from ._build_service_builder_operations import BuildServiceBuilderOperations +from ._build_service_agent_pool_operations import BuildServiceAgentPoolOperations +from ._monitoring_settings_operations import MonitoringSettingsOperations +from ._apps_operations import AppsOperations +from ._bindings_operations import BindingsOperations +from ._storages_operations import StoragesOperations +from ._certificates_operations import CertificatesOperations +from ._custom_domains_operations import CustomDomainsOperations +from ._deployments_operations import DeploymentsOperations +from ._operations import Operations +from ._runtime_versions_operations import RuntimeVersionsOperations +from ._skus_operations import SkusOperations +from ._gateways_operations import GatewaysOperations +from ._gateway_route_configs_operations import GatewayRouteConfigsOperations +from ._gateway_custom_domains_operations import GatewayCustomDomainsOperations +from ._api_portals_operations import ApiPortalsOperations +from ._api_portal_custom_domains_operations import ApiPortalCustomDomainsOperations +from ._application_accelerators_operations import ApplicationAcceleratorsOperations +from ._customized_accelerators_operations import CustomizedAcceleratorsOperations +from ._predefined_accelerators_operations import PredefinedAcceleratorsOperations + +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__ = [ + "ServicesOperations", + "ConfigServersOperations", + "ConfigurationServicesOperations", + "ServiceRegistriesOperations", + "ApplicationLiveViewsOperations", + "DevToolPortalsOperations", + "BuildServiceOperations", + "BuildpackBindingOperations", + "BuildServiceBuilderOperations", + "BuildServiceAgentPoolOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "StoragesOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", + "GatewaysOperations", + "GatewayRouteConfigsOperations", + "GatewayCustomDomainsOperations", + "ApiPortalsOperations", + "ApiPortalCustomDomainsOperations", + "ApplicationAcceleratorsOperations", + "CustomizedAcceleratorsOperations", + "PredefinedAcceleratorsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_api_portal_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_api_portal_custom_domains_operations.py new file mode 100644 index 000000000000..c422006d4809 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_api_portal_custom_domains_operations.py @@ -0,0 +1,605 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._api_portal_custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApiPortalCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`api_portal_custom_domains` 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, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any + ) -> _models.ApiPortalCustomDomainResource: + """Get the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiPortalCustomDomainResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], + **kwargs: Any + ) -> _models.ApiPortalCustomDomainResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_custom_domain_resource, (IO, bytes)): + _content = api_portal_custom_domain_resource + else: + _json = self._serialize.body(api_portal_custom_domain_resource, "ApiPortalCustomDomainResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: _models.ApiPortalCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Is either a model type or a IO type. Required. + :type api_portal_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + 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, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_name, + api_portal_custom_domain_resource=api_portal_custom_domain_resource, + 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("ApiPortalCustomDomainResource", 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApiPortalCustomDomainResource"]: + """Handle requests to list all API portal custom domains. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiPortalCustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResourceCollection] + + 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, + service_name=service_name, + api_portal_name=api_portal_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiPortalCustomDomainResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_api_portals_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_api_portals_operations.py new file mode 100644 index 000000000000..b948f1cc66d4 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_api_portals_operations.py @@ -0,0 +1,733 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._api_portals_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApiPortalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`api_portals` 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, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> _models.ApiPortalResource: + """Get the API portal and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiPortalResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiPortalResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: Union[_models.ApiPortalResource, IO], + **kwargs: Any + ) -> _models.ApiPortalResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_resource, (IO, bytes)): + _content = api_portal_resource + else: + _json = self._serialize.body(api_portal_resource, "ApiPortalResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApiPortalResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApiPortalResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: _models.ApiPortalResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: Union[_models.ApiPortalResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Is either a + model type or a IO type. Required. + :type api_portal_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + 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, + service_name=service_name, + api_portal_name=api_portal_name, + api_portal_resource=api_portal_resource, + 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("ApiPortalResource", 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, api_portal_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the default API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + api_portal_name=api_portal_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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApiPortalResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiPortalResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiPortalResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") + + request = build_validate_domain_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate_domain.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_application_accelerators_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_application_accelerators_operations.py new file mode 100644 index 000000000000..0cb38105daa3 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_application_accelerators_operations.py @@ -0,0 +1,583 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_accelerators_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApplicationAcceleratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`application_accelerators` 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, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApplicationAcceleratorResource"]: + """Handle requests to list all application accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationAcceleratorResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationAcceleratorResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationAcceleratorResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, application_accelerator_name: str, **kwargs: Any + ) -> _models.ApplicationAcceleratorResource: + """Get the application accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationAcceleratorResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationAcceleratorResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationAcceleratorResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + application_accelerator_resource: Union[_models.ApplicationAcceleratorResource, IO], + **kwargs: Any + ) -> _models.ApplicationAcceleratorResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationAcceleratorResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application_accelerator_resource, (IO, bytes)): + _content = application_accelerator_resource + else: + _json = self._serialize.body(application_accelerator_resource, "ApplicationAcceleratorResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApplicationAcceleratorResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApplicationAcceleratorResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + application_accelerator_resource: _models.ApplicationAcceleratorResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationAcceleratorResource]: + """Create or update the application accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param application_accelerator_resource: The application accelerator for the create or update + operation. Required. + :type application_accelerator_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationAcceleratorResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + application_accelerator_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationAcceleratorResource]: + """Create or update the application accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param application_accelerator_resource: The application accelerator for the create or update + operation. Required. + :type application_accelerator_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationAcceleratorResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + application_accelerator_resource: Union[_models.ApplicationAcceleratorResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationAcceleratorResource]: + """Create or update the application accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param application_accelerator_resource: The application accelerator for the create or update + operation. Is either a model type or a IO type. Required. + :type application_accelerator_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationAcceleratorResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationAcceleratorResource] + 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, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + application_accelerator_resource=application_accelerator_resource, + 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("ApplicationAcceleratorResource", 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.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, application_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, application_accelerator_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the application accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + application_accelerator_name=application_accelerator_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.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_application_live_views_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_application_live_views_operations.py new file mode 100644 index 000000000000..f228b9452ca0 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_application_live_views_operations.py @@ -0,0 +1,581 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._application_live_views_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApplicationLiveViewsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`application_live_views` 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, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApplicationLiveViewResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationLiveViewResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationLiveViewResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationLiveViewResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationLiveViews"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, application_live_view_name: str, **kwargs: Any + ) -> _models.ApplicationLiveViewResource: + """Get the Application Live and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_live_view_name: The name of Application Live View. Required. + :type application_live_view_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationLiveViewResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationLiveViewResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_live_view_name=application_live_view_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationLiveViewResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationLiveViews/{applicationLiveViewName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + application_live_view_name: str, + application_live_view_resource: Union[_models.ApplicationLiveViewResource, IO], + **kwargs: Any + ) -> _models.ApplicationLiveViewResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationLiveViewResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application_live_view_resource, (IO, bytes)): + _content = application_live_view_resource + else: + _json = self._serialize.body(application_live_view_resource, "ApplicationLiveViewResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_live_view_name=application_live_view_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApplicationLiveViewResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApplicationLiveViewResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationLiveViews/{applicationLiveViewName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_live_view_name: str, + application_live_view_resource: _models.ApplicationLiveViewResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationLiveViewResource]: + """Create the default Application Live View or update the existing Application Live View. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_live_view_name: The name of Application Live View. Required. + :type application_live_view_name: str + :param application_live_view_resource: Parameters for the update operation. Required. + :type application_live_view_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationLiveViewResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_live_view_name: str, + application_live_view_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationLiveViewResource]: + """Create the default Application Live View or update the existing Application Live View. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_live_view_name: The name of Application Live View. Required. + :type application_live_view_name: str + :param application_live_view_resource: Parameters for the update operation. Required. + :type application_live_view_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationLiveViewResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_live_view_name: str, + application_live_view_resource: Union[_models.ApplicationLiveViewResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationLiveViewResource]: + """Create the default Application Live View or update the existing Application Live View. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_live_view_name: The name of Application Live View. Required. + :type application_live_view_name: str + :param application_live_view_resource: Parameters for the update operation. Is either a model + type or a IO type. Required. + :type application_live_view_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationLiveViewResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationLiveViewResource] + 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, + service_name=service_name, + application_live_view_name=application_live_view_name, + application_live_view_resource=application_live_view_resource, + 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("ApplicationLiveViewResource", 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.AppPlatform/Spring/{serviceName}/applicationLiveViews/{applicationLiveViewName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, application_live_view_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_live_view_name=application_live_view_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationLiveViews/{applicationLiveViewName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, application_live_view_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Disable the default Application Live View. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_live_view_name: The name of Application Live View. Required. + :type application_live_view_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + application_live_view_name=application_live_view_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.AppPlatform/Spring/{serviceName}/applicationLiveViews/{applicationLiveViewName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_apps_operations.py new file mode 100644 index 000000000000..b0af53507f59 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_apps_operations.py @@ -0,0 +1,1290 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._apps_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_get_resource_upload_url_request, + build_list_request, + build_set_active_deployments_request, + build_update_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`apps` 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, + resource_group_name: str, + service_name: str, + app_name: str, + sync_status: Optional[str] = None, + **kwargs: Any + ) -> _models.AppResource: + """Get an App and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param sync_status: Indicates whether sync status. Default value is None. + :type sync_status: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AppResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + sync_status=sync_status, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> _models.AppResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, + service_name=service_name, + app_name=app_name, + app_resource=app_resource, + 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("AppResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Operation to delete an App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + app_name=app_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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> _models.AppResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + app_resource=app_resource, + 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("AppResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncIterable["_models.AppResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AppResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AppResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + + @distributed_trace_async + async def get_resource_upload_url( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: + """Get an resource upload URL for an App, which may be artifacts or source archive. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceUploadDefinition or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceUploadDefinition + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] + + request = build_get_resource_upload_url_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_resource_upload_url.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + + async def _set_active_deployments_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], + **kwargs: Any + ) -> _models.AppResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(active_deployment_collection, (IO, bytes)): + _content = active_deployment_collection + else: + _json = self._serialize.body(active_deployment_collection, "ActiveDeploymentCollection") + + request = build_set_active_deployments_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._set_active_deployments_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _set_active_deployments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + + @overload + async def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: _models.ActiveDeploymentCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ActiveDeploymentCollection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Is either a model + type or a IO type. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ActiveDeploymentCollection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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._set_active_deployments_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + active_deployment_collection=active_deployment_collection, + 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("AppResource", 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_set_active_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") + + request = build_validate_domain_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate_domain.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_bindings_operations.py new file mode 100644 index 000000000000..84cbf12873cf --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_bindings_operations.py @@ -0,0 +1,857 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._bindings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`bindings` 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, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: + """Get a Binding and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BindingResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> _models.BindingResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, + service_name=service_name, + app_name=app_name, + binding_name=binding_name, + binding_resource=binding_resource, + 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("BindingResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, binding_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Operation to delete a Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + app_name=app_name, + binding_name=binding_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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> _models.BindingResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_name, + binding_resource=binding_resource, + 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("BindingResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BindingResource"]: + """Handles requests to list all resources in an App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type 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 BindingResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] + + 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, + service_name=service_name, + app_name=app_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BindingResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_build_service_agent_pool_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_build_service_agent_pool_operations.py new file mode 100644 index 000000000000..822921c345bf --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_build_service_agent_pool_operations.py @@ -0,0 +1,482 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._build_service_agent_pool_operations import ( + build_get_request, + build_list_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BuildServiceAgentPoolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service_agent_pool` 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, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildServiceAgentPoolResource"]: + """List build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildServiceAgentPoolResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResourceCollection] + + 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, + service_name=service_name, + build_service_name=build_service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BuildServiceAgentPoolResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: + """Get build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildServiceAgentPoolResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + agent_pool_name=agent_pool_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + + async def _update_put_initial( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], + **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(agent_pool_resource, (IO, bytes)): + _content = agent_pool_resource + else: + _json = self._serialize.body(agent_pool_resource, "BuildServiceAgentPoolResource") + + request = build_update_put_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_put_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: _models.BuildServiceAgentPoolResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + 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_put_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + agent_pool_name=agent_pool_name, + agent_pool_resource=agent_pool_resource, + 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("BuildServiceAgentPoolResource", 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_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_build_service_builder_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_build_service_builder_operations.py new file mode 100644 index 000000000000..093fbc0fe0df --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_build_service_builder_operations.py @@ -0,0 +1,671 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._build_service_builder_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_deployments_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BuildServiceBuilderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service_builder` 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, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.BuilderResource: + """Get a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuilderResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuilderResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: Union[_models.BuilderResource, IO], + **kwargs: Any + ) -> _models.BuilderResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(builder_resource, (IO, bytes)): + _content = builder_resource + else: + _json = self._serialize.body(builder_resource, "BuilderResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BuilderResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BuilderResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: _models.BuilderResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: Union[_models.BuilderResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Is either a + model type or a IO type. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + builder_resource=builder_resource, + 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("BuilderResource", 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, build_service_name: str, builder_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuilderResource"]: + """List KPack builders result. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuilderResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResourceCollection] + + 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, + service_name=service_name, + build_service_name=build_service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BuilderResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore + + @distributed_trace_async + async def list_deployments( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.DeploymentList: + """List deployments that are using the builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentList or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentList + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentList] + + request = build_list_deployments_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_deployments.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeploymentList", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/listUsingDeployments"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_build_service_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_build_service_operations.py new file mode 100644 index 000000000000..19f83550b328 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_build_service_operations.py @@ -0,0 +1,1147 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.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._build_service_operations import ( + build_create_or_update_build_request, + build_get_build_request, + build_get_build_result_log_request, + build_get_build_result_request, + build_get_build_service_request, + build_get_resource_upload_url_request, + build_get_supported_buildpack_request, + build_get_supported_stack_request, + build_list_build_results_request, + build_list_build_services_request, + build_list_builds_request, + build_list_supported_buildpacks_request, + build_list_supported_stacks_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BuildServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`build_service` 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_build_services( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildService"]: + """List build services resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildService or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildService] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceCollection] + + 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_build_services_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_build_services.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BuildServiceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_build_services.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore + + @distributed_trace_async + async def get_build_service( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.BuildService: + """Get a build service resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildService or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildService + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildService] + + request = build_get_build_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build_service.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildService", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore + + @distributed_trace + def list_builds( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Build"]: + """List KPack builds. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Build or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.Build] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildCollection] + + 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_builds_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_builds.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BuildCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_builds.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore + + @distributed_trace_async + async def get_build( + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> _models.Build: + """Get a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Build + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] + + request = build_get_build_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Build", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + + @overload + async def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: _models.Build, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Build + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: Union[_models.Build, IO], + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type build: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Build or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Build + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build, (IO, bytes)): + _content = build + else: + _json = self._serialize.body(build, "Build") + + request = build_create_or_update_build_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_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_build.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Build", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Build", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + + @distributed_trace + def list_build_results( + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildResult"]: + """List KPack build results. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildResult] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultCollection] + + 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_build_results_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_build_results.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BuildResultCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_build_results.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore + + @distributed_trace_async + async def get_build_result( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build_result_name: str, + **kwargs: Any + ) -> _models.BuildResult: + """Get a KPack build result. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build_result_name: The name of the build result resource. Required. + :type build_result_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildResult + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResult] + + request = build_get_build_result_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + build_result_name=build_result_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build_result.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore + + @distributed_trace_async + async def get_build_result_log( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build_result_name: str, + **kwargs: Any + ) -> _models.BuildResultLog: + """Get a KPack build result log download URL. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build_result_name: The name of the build result resource. Required. + :type build_result_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildResultLog or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildResultLog + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultLog] + + request = build_get_build_result_log_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + build_result_name=build_result_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build_result_log.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildResultLog", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build_result_log.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore + + @distributed_trace_async + async def get_resource_upload_url( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: + """Get an resource upload URL for build service, which may be artifacts or source archive. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceUploadDefinition or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceUploadDefinition + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] + + request = build_get_resource_upload_url_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_resource_upload_url.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore + + @distributed_trace_async + async def list_supported_buildpacks( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedBuildpacksCollection: + """Get all supported buildpacks. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedBuildpacksCollection or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedBuildpacksCollection + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpacksCollection] + + request = build_list_supported_buildpacks_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_supported_buildpacks.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedBuildpacksCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_supported_buildpacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore + + @distributed_trace_async + async def get_supported_buildpack( + self, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, **kwargs: Any + ) -> _models.SupportedBuildpackResource: + """Get the supported buildpack resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param buildpack_name: The name of the buildpack resource. Required. + :type buildpack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedBuildpackResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedBuildpackResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpackResource] + + request = build_get_supported_buildpack_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + buildpack_name=buildpack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_supported_buildpack.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedBuildpackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_supported_buildpack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore + + @distributed_trace_async + async def list_supported_stacks( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedStacksCollection: + """Get all supported stacks. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedStacksCollection or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedStacksCollection + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStacksCollection] + + request = build_list_supported_stacks_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_supported_stacks.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedStacksCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_supported_stacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore + + @distributed_trace_async + async def get_supported_stack( + self, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, **kwargs: Any + ) -> _models.SupportedStackResource: + """Get the supported stack resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param stack_name: The name of the stack resource. Required. + :type stack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedStackResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedStackResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStackResource] + + request = build_get_supported_stack_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + stack_name=stack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_supported_stack.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedStackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_supported_stack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_buildpack_binding_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_buildpack_binding_operations.py new file mode 100644 index 000000000000..637660a7907a --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_buildpack_binding_operations.py @@ -0,0 +1,645 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._buildpack_binding_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BuildpackBindingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`buildpack_binding` 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, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + **kwargs: Any + ) -> _models.BuildpackBindingResource: + """Get a buildpack binding by name. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildpackBindingResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> _models.BuildpackBindingResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(buildpack_binding, (IO, bytes)): + _content = buildpack_binding + else: + _json = self._serialize.body(buildpack_binding, "BuildpackBindingResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: _models.BuildpackBindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildpackBindingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildpackBindingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. Is + either a model type or a IO type. Required. + :type buildpack_binding: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BuildpackBindingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_name, + buildpack_binding=buildpack_binding, + 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("BuildpackBindingResource", 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Operation to delete a Buildpack Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildpackBindingResource"]: + """Handles requests to list all buildpack bindings in a builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResourceCollection] + + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BuildpackBindingResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_certificates_operations.py new file mode 100644 index 000000000000..613cef733d0e --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_certificates_operations.py @@ -0,0 +1,583 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`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_async + async def get( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: + """Get the certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: Union[_models.CertificateResource, IO], + **kwargs: Any + ) -> _models.CertificateResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_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_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: Union[_models.CertificateResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, + service_name=service_name, + certificate_name=certificate_name, + certificate_resource=certificate_resource, + 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("CertificateResource", 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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, certificate_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + certificate_name=certificate_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + certificate_name=certificate_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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CertificateResource"]: + """List all the certificates of one user. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CertificateResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CertificateResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_config_servers_operations.py new file mode 100644 index 000000000000..590e58523698 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_config_servers_operations.py @@ -0,0 +1,813 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._config_servers_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`config_servers` 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, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: + """Get the config server and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigServerResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + async def _update_put_initial( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> _models.ConfigServerResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_put_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + config_server_resource=config_server_resource, + 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("ConfigServerResource", 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_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + async def _update_patch_initial( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> _models.ConfigServerResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_patch_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + config_server_resource=config_server_resource, + 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("ConfigServerResource", 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_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + async def _validate_initial( + self, + resource_group_name: str, + service_name: str, + config_server_settings: Union[_models.ConfigServerSettings, IO], + **kwargs: Any + ) -> _models.ConfigServerSettingsValidateResult: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._validate_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: Union[_models.ConfigServerSettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigServerSettingsValidateResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerSettingsValidateResult] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + config_server_settings=config_server_settings, + 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("ConfigServerSettingsValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_configuration_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_configuration_services_operations.py new file mode 100644 index 000000000000..3d80d4dae339 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_configuration_services_operations.py @@ -0,0 +1,827 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._configuration_services_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConfigurationServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`configuration_services` 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, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> _models.ConfigurationServiceResource: + """Get the Application Configuration Service and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationServiceResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], + **kwargs: Any + ) -> _models.ConfigurationServiceResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_service_resource, (IO, bytes)): + _content = configuration_service_resource + else: + _json = self._serialize.body(configuration_service_resource, "ConfigurationServiceResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: _models.ConfigurationServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Is either a model + type or a IO type. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + 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, + service_name=service_name, + configuration_service_name=configuration_service_name, + configuration_service_resource=configuration_service_resource, + 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("ConfigurationServiceResource", 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, configuration_service_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Disable the default Application Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + configuration_service_name=configuration_service_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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationServiceResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConfigurationServiceResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ConfigurationServiceResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore + + async def _validate_initial( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: Union[_models.ConfigurationServiceSettings, IO], + **kwargs: Any + ) -> _models.ConfigurationServiceSettingsValidateResult: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(settings, (IO, bytes)): + _content = settings + else: + _json = self._serialize.body(settings, "ConfigurationServiceSettings") + + request = build_validate_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._validate_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: _models.ConfigurationServiceSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: Union[_models.ConfigurationServiceSettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Is either a model + type or a IO type. Required. + :type settings: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceSettings + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceSettingsValidateResult] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + 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._validate_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_name, + settings=settings, + 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("ConfigurationServiceSettingsValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_custom_domains_operations.py new file mode 100644 index 000000000000..a78bccf7dc4d --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_custom_domains_operations.py @@ -0,0 +1,858 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`custom_domains` 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, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: + """Get the custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CustomDomainResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> _models.CustomDomainResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, + service_name=service_name, + app_name=app_name, + domain_name=domain_name, + domain_resource=domain_resource, + 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("CustomDomainResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, domain_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + app_name=app_name, + domain_name=domain_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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> _models.CustomDomainResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_name, + domain_resource=domain_resource, + 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("CustomDomainResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CustomDomainResource"]: + """List the custom domains of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type 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 CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] + + 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, + service_name=service_name, + app_name=app_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CustomDomainResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_customized_accelerators_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_customized_accelerators_operations.py new file mode 100644 index 000000000000..aede2ddbf02e --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_customized_accelerators_operations.py @@ -0,0 +1,789 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._customized_accelerators_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CustomizedAcceleratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`customized_accelerators` 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, service_name: str, application_accelerator_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CustomizedAcceleratorResource"]: + """Handle requests to list all customized accelerators. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CustomizedAcceleratorResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomizedAcceleratorResourceCollection] + + 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, + service_name=service_name, + application_accelerator_name=application_accelerator_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CustomizedAcceleratorResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + **kwargs: Any + ) -> _models.CustomizedAcceleratorResource: + """Get the customized accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CustomizedAcceleratorResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomizedAcceleratorResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + customized_accelerator_name=customized_accelerator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomizedAcceleratorResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + customized_accelerator_resource: Union[_models.CustomizedAcceleratorResource, IO], + **kwargs: Any + ) -> _models.CustomizedAcceleratorResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomizedAcceleratorResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(customized_accelerator_resource, (IO, bytes)): + _content = customized_accelerator_resource + else: + _json = self._serialize.body(customized_accelerator_resource, "CustomizedAcceleratorResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + customized_accelerator_name=customized_accelerator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CustomizedAcceleratorResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CustomizedAcceleratorResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + customized_accelerator_resource: _models.CustomizedAcceleratorResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomizedAcceleratorResource]: + """Create or update the customized accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_name: str + :param customized_accelerator_resource: The customized accelerator for the create or update + operation. Required. + :type customized_accelerator_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomizedAcceleratorResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + customized_accelerator_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomizedAcceleratorResource]: + """Create or update the customized accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_name: str + :param customized_accelerator_resource: The customized accelerator for the create or update + operation. Required. + :type customized_accelerator_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomizedAcceleratorResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + customized_accelerator_resource: Union[_models.CustomizedAcceleratorResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomizedAcceleratorResource]: + """Create or update the customized accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_name: str + :param customized_accelerator_resource: The customized accelerator for the create or update + operation. Is either a model type or a IO type. Required. + :type customized_accelerator_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CustomizedAcceleratorResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomizedAcceleratorResource] + 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, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + customized_accelerator_name=customized_accelerator_name, + customized_accelerator_resource=customized_accelerator_resource, + 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("CustomizedAcceleratorResource", 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.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + customized_accelerator_name=customized_accelerator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the customized accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + customized_accelerator_name=customized_accelerator_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.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}"} # type: ignore + + @overload + async def validate( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + properties: _models.CustomizedAcceleratorProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.CustomizedAcceleratorValidateResult]: + """Check the customized accelerator are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_name: str + :param properties: Customized accelerator properties to be validated. Required. + :type properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomizedAcceleratorValidateResult or None or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorValidateResult + or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.CustomizedAcceleratorValidateResult]: + """Check the customized accelerator are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_name: str + :param properties: Customized accelerator properties to be validated. Required. + :type properties: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomizedAcceleratorValidateResult or None or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorValidateResult + or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + properties: Union[_models.CustomizedAcceleratorProperties, IO], + **kwargs: Any + ) -> Optional[_models.CustomizedAcceleratorValidateResult]: + """Check the customized accelerator are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_name: str + :param properties: Customized accelerator properties to be validated. Is either a model type or + a IO type. Required. + :type properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomizedAcceleratorValidateResult or None or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorValidateResult + or 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 = case_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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.CustomizedAcceleratorValidateResult]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "CustomizedAcceleratorProperties") + + request = build_validate_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + customized_accelerator_name=customized_accelerator_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("CustomizedAcceleratorValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_deployments_operations.py new file mode 100644 index 000000000000..3677dbe69d16 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_deployments_operations.py @@ -0,0 +1,2571 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._deployments_operations import ( + build_create_or_update_request, + build_delete_request, + build_disable_remote_debugging_request, + build_enable_remote_debugging_request, + build_generate_heap_dump_request, + build_generate_thread_dump_request, + build_get_log_file_url_request, + build_get_remote_debugging_config_request, + build_get_request, + build_list_for_cluster_request, + build_list_request, + build_restart_request, + build_start_jfr_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`deployments` 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, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: + """Get a Deployment and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> _models.DeploymentResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + deployment_resource=deployment_resource, + 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("DeploymentResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Operation to delete a Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> _models.DeploymentResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + deployment_resource=deployment_resource, + 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("DeploymentResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + app_name: str, + version: Optional[List[str]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.DeploymentResource"]: + """Handles requests to list all resources in an App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param version: Version of the deployments to be listed. Default value is None. + :type version: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] + + 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, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + version=version, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeploymentResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + + @distributed_trace + def list_for_cluster( + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentResource"]: + """List deployments for a certain service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param version: Version of the deployments to be listed. Default value is None. + :type version: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] + + 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_for_cluster_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + version=version, + api_version=api_version, + template_url=self.list_for_cluster.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeploymentResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + + async def _start_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._start_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + + @distributed_trace_async + async def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start the deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._start_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + + async def _stop_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._stop_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + + @distributed_trace_async + async def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Stop the deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._stop_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + + async def _restart_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._restart_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + + @distributed_trace_async + async def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restart the deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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._restart_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + + async def _enable_remote_debugging_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[Union[_models.RemoteDebuggingPayload, IO]] = None, + **kwargs: Any + ) -> _models.RemoteDebugging: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(remote_debugging_payload, (IO, bytes)): + _content = remote_debugging_payload + else: + if remote_debugging_payload is not None: + _json = self._serialize.body(remote_debugging_payload, "RemoteDebuggingPayload") + else: + _json = None + + request = build_enable_remote_debugging_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._enable_remote_debugging_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _enable_remote_debugging_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/enableRemoteDebugging"} # type: ignore + + @overload + async def begin_enable_remote_debugging( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[_models.RemoteDebuggingPayload] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RemoteDebugging]: + """Enable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param remote_debugging_payload: Parameters for enable remote debugging. Default value is None. + :type remote_debugging_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.RemoteDebuggingPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.RemoteDebugging] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_enable_remote_debugging( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RemoteDebugging]: + """Enable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param remote_debugging_payload: Parameters for enable remote debugging. Default value is None. + :type remote_debugging_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.RemoteDebugging] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_enable_remote_debugging( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[Union[_models.RemoteDebuggingPayload, IO]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.RemoteDebugging]: + """Enable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param remote_debugging_payload: Parameters for enable remote debugging. Is either a model type + or a IO type. Default value is None. + :type remote_debugging_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.RemoteDebuggingPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.RemoteDebugging] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + 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._enable_remote_debugging_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + remote_debugging_payload=remote_debugging_payload, + 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("RemoteDebugging", 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_enable_remote_debugging.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/enableRemoteDebugging"} # type: ignore + + async def _disable_remote_debugging_initial( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.RemoteDebugging: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + + request = build_disable_remote_debugging_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._disable_remote_debugging_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _disable_remote_debugging_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/disableRemoteDebugging"} # type: ignore + + @distributed_trace_async + async def begin_disable_remote_debugging( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.RemoteDebugging]: + """Disable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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 RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.RemoteDebugging] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + 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._disable_remote_debugging_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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): + deserialized = self._deserialize("RemoteDebugging", 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_disable_remote_debugging.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/disableRemoteDebugging"} # type: ignore + + @distributed_trace_async + async def get_remote_debugging_config( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.RemoteDebugging: + """Get remote debugging config. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RemoteDebugging or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.RemoteDebugging + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + + request = build_get_remote_debugging_config_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_remote_debugging_config.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_remote_debugging_config.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getRemoteDebuggingConfig"} # type: ignore + + @distributed_trace_async + async def get_log_file_url( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: + """Get deployment log file URL. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogFileUrlResponse or None or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.LogFileUrlResponse or 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] + + request = build_get_log_file_url_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_log_file_url.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore + + async def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_heap_dump_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._generate_heap_dump_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _generate_heap_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + + @overload + async def begin_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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._generate_heap_dump_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + diagnostic_parameters=diagnostic_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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_generate_heap_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + + async def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_thread_dump_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._generate_thread_dump_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _generate_thread_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + @overload + async def begin_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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._generate_thread_dump_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + diagnostic_parameters=diagnostic_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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_generate_thread_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + async def _start_jfr_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_start_jfr_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._start_jfr_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_jfr_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + + @overload + async def begin_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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._start_jfr_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + diagnostic_parameters=diagnostic_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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_start_jfr.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_dev_tool_portals_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_dev_tool_portals_operations.py new file mode 100644 index 000000000000..1ea2ed0f45ac --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_dev_tool_portals_operations.py @@ -0,0 +1,581 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._dev_tool_portals_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DevToolPortalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`dev_tool_portals` 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, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DevToolPortalResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DevToolPortalResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DevToolPortalResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DevToolPortalResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/DevToolPortals"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, dev_tool_portal_name: str, **kwargs: Any + ) -> _models.DevToolPortalResource: + """Get the Application Live and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param dev_tool_portal_name: The name of Dev Tool Portal. Required. + :type dev_tool_portal_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DevToolPortalResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DevToolPortalResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + dev_tool_portal_name=dev_tool_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DevToolPortalResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/DevToolPortals/{devToolPortalName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + dev_tool_portal_name: str, + dev_tool_portal_resource: Union[_models.DevToolPortalResource, IO], + **kwargs: Any + ) -> _models.DevToolPortalResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DevToolPortalResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(dev_tool_portal_resource, (IO, bytes)): + _content = dev_tool_portal_resource + else: + _json = self._serialize.body(dev_tool_portal_resource, "DevToolPortalResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + dev_tool_portal_name=dev_tool_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DevToolPortalResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("DevToolPortalResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/DevToolPortals/{devToolPortalName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + dev_tool_portal_name: str, + dev_tool_portal_resource: _models.DevToolPortalResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DevToolPortalResource]: + """Create the default Dev Tool Portal or update the existing Dev Tool Portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param dev_tool_portal_name: The name of Dev Tool Portal. Required. + :type dev_tool_portal_name: str + :param dev_tool_portal_resource: Parameters for the create or update operation. Required. + :type dev_tool_portal_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DevToolPortalResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + dev_tool_portal_name: str, + dev_tool_portal_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DevToolPortalResource]: + """Create the default Dev Tool Portal or update the existing Dev Tool Portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param dev_tool_portal_name: The name of Dev Tool Portal. Required. + :type dev_tool_portal_name: str + :param dev_tool_portal_resource: Parameters for the create or update operation. Required. + :type dev_tool_portal_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DevToolPortalResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + dev_tool_portal_name: str, + dev_tool_portal_resource: Union[_models.DevToolPortalResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DevToolPortalResource]: + """Create the default Dev Tool Portal or update the existing Dev Tool Portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param dev_tool_portal_name: The name of Dev Tool Portal. Required. + :type dev_tool_portal_name: str + :param dev_tool_portal_resource: Parameters for the create or update operation. Is either a + model type or a IO type. Required. + :type dev_tool_portal_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DevToolPortalResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DevToolPortalResource] + 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, + service_name=service_name, + dev_tool_portal_name=dev_tool_portal_name, + dev_tool_portal_resource=dev_tool_portal_resource, + 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("DevToolPortalResource", 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.AppPlatform/Spring/{serviceName}/DevToolPortals/{devToolPortalName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, dev_tool_portal_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + dev_tool_portal_name=dev_tool_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/DevToolPortals/{devToolPortalName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, dev_tool_portal_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Disable the default Dev Tool Portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param dev_tool_portal_name: The name of Dev Tool Portal. Required. + :type dev_tool_portal_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + dev_tool_portal_name=dev_tool_portal_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.AppPlatform/Spring/{serviceName}/DevToolPortals/{devToolPortalName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_gateway_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_gateway_custom_domains_operations.py new file mode 100644 index 000000000000..1170eb00c24f --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_gateway_custom_domains_operations.py @@ -0,0 +1,605 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._gateway_custom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GatewayCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateway_custom_domains` 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, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any + ) -> _models.GatewayCustomDomainResource: + """Get the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayCustomDomainResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], + **kwargs: Any + ) -> _models.GatewayCustomDomainResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_custom_domain_resource, (IO, bytes)): + _content = gateway_custom_domain_resource + else: + _json = self._serialize.body(gateway_custom_domain_resource, "GatewayCustomDomainResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: _models.GatewayCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Is either a model type or a IO type. Required. + :type gateway_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + 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, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_name, + gateway_custom_domain_resource=gateway_custom_domain_resource, + 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("GatewayCustomDomainResource", 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, gateway_name: str, domain_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayCustomDomainResource"]: + """Handle requests to list all Spring Cloud Gateway custom domains. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayCustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResourceCollection] + + 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, + service_name=service_name, + gateway_name=gateway_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GatewayCustomDomainResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_gateway_route_configs_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_gateway_route_configs_operations.py new file mode 100644 index 000000000000..2449ff32ac51 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_gateway_route_configs_operations.py @@ -0,0 +1,608 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._gateway_route_configs_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GatewayRouteConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateway_route_configs` 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, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any + ) -> _models.GatewayRouteConfigResource: + """Get the Spring Cloud Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayRouteConfigResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], + **kwargs: Any + ) -> _models.GatewayRouteConfigResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_route_config_resource, (IO, bytes)): + _content = gateway_route_config_resource + else: + _json = self._serialize.body(gateway_route_config_resource, "GatewayRouteConfigResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: _models.GatewayRouteConfigResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayRouteConfigResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayRouteConfigResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Is either a model type or a IO type. Required. + :type gateway_route_config_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayRouteConfigResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + 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, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_name, + gateway_route_config_resource=gateway_route_config_resource, + 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("GatewayRouteConfigResource", 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the Spring Cloud Gateway route config. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayRouteConfigResource"]: + """Handle requests to list all Spring Cloud Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayRouteConfigResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResourceCollection] + + 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, + service_name=service_name, + gateway_name=gateway_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GatewayRouteConfigResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_gateways_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_gateways_operations.py new file mode 100644 index 000000000000..0ddf6f4c0824 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_gateways_operations.py @@ -0,0 +1,800 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._gateways_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_env_secrets_request, + build_list_request, + build_validate_domain_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GatewaysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`gateways` 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, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> _models.GatewayResource: + """Get the Spring Cloud Gateway and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GatewayResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: Union[_models.GatewayResource, IO], + **kwargs: Any + ) -> _models.GatewayResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_resource, (IO, bytes)): + _content = gateway_resource + else: + _json = self._serialize.body(gateway_resource, "GatewayResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GatewayResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GatewayResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: _models.GatewayResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: Union[_models.GatewayResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Is either a model type + or a IO type. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + 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, + service_name=service_name, + gateway_name=gateway_name, + gateway_resource=gateway_resource, + 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("GatewayResource", 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, gateway_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Disable the default Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + gateway_name=gateway_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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @distributed_trace_async + async def list_env_secrets( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> Dict[str, str]: + """List sensitive environment variables of Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str or the result of cls(response) + :rtype: dict[str, str] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + + request = build_list_env_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_env_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_env_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/listEnvSecrets"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GatewayResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") + + request = build_validate_domain_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate_domain.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_monitoring_settings_operations.py new file mode 100644 index 000000000000..09fe821be164 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_monitoring_settings_operations.py @@ -0,0 +1,583 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._monitoring_settings_operations import ( + build_get_request, + build_update_patch_request, + build_update_put_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`monitoring_settings` 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, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.MonitoringSettingResource: + """Get the Monitoring Setting and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + async def _update_put_initial( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> _models.MonitoringSettingResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_put_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + monitoring_setting_resource=monitoring_setting_resource, + 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("MonitoringSettingResource", 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_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + async def _update_patch_initial( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> _models.MonitoringSettingResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_patch_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringSettingResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + monitoring_setting_resource=monitoring_setting_resource, + 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("MonitoringSettingResource", 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_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_operations.py new file mode 100644 index 000000000000..151c37611b16 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_operations.py @@ -0,0 +1,139 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDetail"]: + """Lists all of the available REST API operations of the Microsoft.AppPlatform provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationDetail or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.OperationDetail] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableOperations] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AvailableOperations", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_predefined_accelerators_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_predefined_accelerators_operations.py new file mode 100644 index 000000000000..9f7274c07c58 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_predefined_accelerators_operations.py @@ -0,0 +1,495 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._predefined_accelerators_operations import ( + build_disable_request, + build_enable_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PredefinedAcceleratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`predefined_accelerators` 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, service_name: str, application_accelerator_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PredefinedAcceleratorResource"]: + """Handle requests to list all predefined accelerators. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PredefinedAcceleratorResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.PredefinedAcceleratorResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PredefinedAcceleratorResourceCollection] + + 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, + service_name=service_name, + application_accelerator_name=application_accelerator_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PredefinedAcceleratorResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + predefined_accelerator_name: str, + **kwargs: Any + ) -> _models.PredefinedAcceleratorResource: + """Get the predefined accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param predefined_accelerator_name: The name of the predefined accelerator. Required. + :type predefined_accelerator_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PredefinedAcceleratorResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.PredefinedAcceleratorResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PredefinedAcceleratorResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + predefined_accelerator_name=predefined_accelerator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PredefinedAcceleratorResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators/{predefinedAcceleratorName}"} # type: ignore + + async def _disable_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + predefined_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_disable_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + predefined_accelerator_name=predefined_accelerator_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._disable_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _disable_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators/{predefinedAcceleratorName}/disable"} # type: ignore + + @distributed_trace_async + async def begin_disable( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + predefined_accelerator_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Disable predefined accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param predefined_accelerator_name: The name of the predefined accelerator. Required. + :type predefined_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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._disable_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + predefined_accelerator_name=predefined_accelerator_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_disable.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators/{predefinedAcceleratorName}/disable"} # type: ignore + + async def _enable_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + predefined_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_enable_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + predefined_accelerator_name=predefined_accelerator_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._enable_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _enable_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators/{predefinedAcceleratorName}/enable"} # type: ignore + + @distributed_trace_async + async def begin_enable( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + predefined_accelerator_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Enable predefined accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param predefined_accelerator_name: The name of the predefined accelerator. Required. + :type predefined_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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._enable_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + predefined_accelerator_name=predefined_accelerator_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_enable.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators/{predefinedAcceleratorName}/enable"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_runtime_versions_operations.py new file mode 100644 index 000000000000..6e42528aed9e --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_runtime_versions_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. +# -------------------------------------------------------------------------- +import sys +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._runtime_versions_operations import build_list_runtime_versions_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`runtime_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: + """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AvailableRuntimeVersions or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AvailableRuntimeVersions + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] + + request = build_list_runtime_versions_request( + api_version=api_version, + template_url=self.list_runtime_versions.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_service_registries_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_service_registries_operations.py new file mode 100644 index 000000000000..b813a5a22cba --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_service_registries_operations.py @@ -0,0 +1,468 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._service_registries_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ServiceRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`service_registries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: + """Get the Service Registry and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param service_registry_name: The name of Service Registry. Required. + :type service_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServiceRegistryResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceRegistryResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + async def _create_or_update_initial( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceRegistryResource]: + """Create the default Service Registry or update the existing Service Registry. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param service_registry_name: The name of Service Registry. Required. + :type service_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceRegistryResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceRegistryResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + 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, + service_name=service_name, + service_registry_name=service_registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ServiceRegistryResource", 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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Disable the default Service Registry. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param service_registry_name: The name of Service Registry. Required. + :type service_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + service_registry_name=service_registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServiceRegistryResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServiceRegistryResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceRegistryResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceRegistryResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_services_operations.py new file mode 100644 index 000000000000..f38494f913e7 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_services_operations.py @@ -0,0 +1,1523 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._services_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_disable_test_endpoint_request, + build_enable_test_endpoint_request, + build_get_request, + build_list_by_subscription_request, + build_list_request, + build_list_test_keys_request, + build_regenerate_test_key_request, + build_start_request, + build_stop_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`services` 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, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: + """Get a Service and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServiceResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + async def _create_or_update_initial( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + resource: _models.ServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, + service_name=service_name, + resource=resource, + 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("ServiceResource", 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.AppPlatform/Spring/{serviceName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Operation to delete a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_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.AppPlatform/Spring/{serviceName}"} # type: ignore + + async def _update_initial( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: _models.ServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + resource=resource, + 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("ServiceResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @distributed_trace_async + async def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: + """List test keys for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.TestKeys + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + request = build_list_test_keys_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_test_keys.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.TestKeys + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") + + request = build_regenerate_test_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.regenerate_test_key.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore + + @distributed_trace_async + async def disable_test_endpoint( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + """Disable test endpoint functionality for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_disable_test_endpoint_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.disable_test_endpoint.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore + + @distributed_trace_async + async def enable_test_endpoint( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.TestKeys: + """Enable test endpoint functionality for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.TestKeys + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + request = build_enable_test_endpoint_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.enable_test_endpoint.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore + + async def _stop_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._stop_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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + + @distributed_trace_async + async def begin_stop(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Stop a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._stop_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_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_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + + async def _start_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._start_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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + + @distributed_trace_async + async def begin_start(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Start a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._start_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_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_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + + @overload + async def check_name_availability( + self, + location: str, + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.NameAvailability + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") + + request = build_check_name_availability_request( + location=location, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NameAvailability", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: + """Handles requests to list all resources in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServiceResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] + + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceResourceList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ServiceResource"]: + """Handles requests to list all resources in a resource group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] + + 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, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceResourceList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_skus_operations.py new file mode 100644 index 000000000000..eb73f1f8d553 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_skus_operations.py @@ -0,0 +1,140 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._skus_operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`skus` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceSku"]: + """Lists all of the available skus of the Microsoft.AppPlatform provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceSku or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSku] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceSkuCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_storages_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_storages_operations.py new file mode 100644 index 000000000000..a3b99ae72eec --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/aio/operations/_storages_operations.py @@ -0,0 +1,582 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._storages_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class StoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.aio.AppPlatformManagementClient`'s + :attr:`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 get( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> _models.StorageResource: + """Get the storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: Union[_models.StorageResource, IO], + **kwargs: Any + ) -> _models.StorageResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_resource, (IO, bytes)): + _content = storage_resource + else: + _json = self._serialize.body(storage_resource, "StorageResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_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_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("StorageResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("StorageResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("StorageResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: _models.StorageResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: Union[_models.StorageResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + 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, + service_name=service_name, + storage_name=storage_name, + storage_resource=storage_resource, + 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("StorageResource", 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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, storage_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + storage_name=storage_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + storage_name=storage_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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageResource"]: + """List all the storages of one Azure Spring Apps resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StorageResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/models/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/models/__init__.py new file mode 100644 index 000000000000..19f10b1eb413 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/models/__init__.py @@ -0,0 +1,543 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import AcceleratorAuthSetting +from ._models_py3 import AcceleratorBasicAuthSetting +from ._models_py3 import AcceleratorGitRepository +from ._models_py3 import AcceleratorPublicSetting +from ._models_py3 import AcceleratorSshSetting +from ._models_py3 import ActiveDeploymentCollection +from ._models_py3 import ApiPortalCustomDomainProperties +from ._models_py3 import ApiPortalCustomDomainResource +from ._models_py3 import ApiPortalCustomDomainResourceCollection +from ._models_py3 import ApiPortalInstance +from ._models_py3 import ApiPortalProperties +from ._models_py3 import ApiPortalResource +from ._models_py3 import ApiPortalResourceCollection +from ._models_py3 import ApiPortalResourceRequests +from ._models_py3 import AppResource +from ._models_py3 import AppResourceCollection +from ._models_py3 import AppResourceProperties +from ._models_py3 import AppVNetAddons +from ._models_py3 import ApplicationAcceleratorComponent +from ._models_py3 import ApplicationAcceleratorInstance +from ._models_py3 import ApplicationAcceleratorProperties +from ._models_py3 import ApplicationAcceleratorResource +from ._models_py3 import ApplicationAcceleratorResourceCollection +from ._models_py3 import ApplicationAcceleratorResourceRequests +from ._models_py3 import ApplicationInsightsAgentVersions +from ._models_py3 import ApplicationLiveViewComponent +from ._models_py3 import ApplicationLiveViewInstance +from ._models_py3 import ApplicationLiveViewProperties +from ._models_py3 import ApplicationLiveViewResource +from ._models_py3 import ApplicationLiveViewResourceCollection +from ._models_py3 import ApplicationLiveViewResourceRequests +from ._models_py3 import AvailableOperations +from ._models_py3 import AvailableRuntimeVersions +from ._models_py3 import AzureFileVolume +from ._models_py3 import BindingResource +from ._models_py3 import BindingResourceCollection +from ._models_py3 import BindingResourceProperties +from ._models_py3 import Build +from ._models_py3 import BuildCollection +from ._models_py3 import BuildProperties +from ._models_py3 import BuildResourceRequests +from ._models_py3 import BuildResult +from ._models_py3 import BuildResultCollection +from ._models_py3 import BuildResultLog +from ._models_py3 import BuildResultProperties +from ._models_py3 import BuildResultUserSourceInfo +from ._models_py3 import BuildService +from ._models_py3 import BuildServiceAgentPoolProperties +from ._models_py3 import BuildServiceAgentPoolResource +from ._models_py3 import BuildServiceAgentPoolResourceCollection +from ._models_py3 import BuildServiceAgentPoolSizeProperties +from ._models_py3 import BuildServiceCollection +from ._models_py3 import BuildServiceProperties +from ._models_py3 import BuildServicePropertiesResourceRequests +from ._models_py3 import BuildStageProperties +from ._models_py3 import BuilderProperties +from ._models_py3 import BuilderResource +from ._models_py3 import BuilderResourceCollection +from ._models_py3 import BuildpackBindingLaunchProperties +from ._models_py3 import BuildpackBindingProperties +from ._models_py3 import BuildpackBindingResource +from ._models_py3 import BuildpackBindingResourceCollection +from ._models_py3 import BuildpackProperties +from ._models_py3 import BuildpacksGroupProperties +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificateResource +from ._models_py3 import CertificateResourceCollection +from ._models_py3 import CloudErrorBody +from ._models_py3 import ClusterResourceProperties +from ._models_py3 import ConfigServerGitProperty +from ._models_py3 import ConfigServerProperties +from ._models_py3 import ConfigServerResource +from ._models_py3 import ConfigServerSettings +from ._models_py3 import ConfigServerSettingsErrorRecord +from ._models_py3 import ConfigServerSettingsValidateResult +from ._models_py3 import ConfigurationServiceGitProperty +from ._models_py3 import ConfigurationServiceGitPropertyValidateResult +from ._models_py3 import ConfigurationServiceGitRepository +from ._models_py3 import ConfigurationServiceInstance +from ._models_py3 import ConfigurationServiceProperties +from ._models_py3 import ConfigurationServiceResource +from ._models_py3 import ConfigurationServiceResourceCollection +from ._models_py3 import ConfigurationServiceResourceRequests +from ._models_py3 import ConfigurationServiceSettings +from ._models_py3 import ConfigurationServiceSettingsValidateResult +from ._models_py3 import ContainerProbeSettings +from ._models_py3 import ContentCertificateProperties +from ._models_py3 import CustomContainer +from ._models_py3 import CustomContainerUserSourceInfo +from ._models_py3 import CustomDomainProperties +from ._models_py3 import CustomDomainResource +from ._models_py3 import CustomDomainResourceCollection +from ._models_py3 import CustomDomainValidatePayload +from ._models_py3 import CustomDomainValidateResult +from ._models_py3 import CustomPersistentDiskProperties +from ._models_py3 import CustomPersistentDiskResource +from ._models_py3 import CustomizedAcceleratorProperties +from ._models_py3 import CustomizedAcceleratorResource +from ._models_py3 import CustomizedAcceleratorResourceCollection +from ._models_py3 import CustomizedAcceleratorValidateResult +from ._models_py3 import DeploymentInstance +from ._models_py3 import DeploymentList +from ._models_py3 import DeploymentResource +from ._models_py3 import DeploymentResourceCollection +from ._models_py3 import DeploymentResourceProperties +from ._models_py3 import DeploymentSettings +from ._models_py3 import DevToolPortalFeatureDetail +from ._models_py3 import DevToolPortalFeatureSettings +from ._models_py3 import DevToolPortalInstance +from ._models_py3 import DevToolPortalProperties +from ._models_py3 import DevToolPortalResource +from ._models_py3 import DevToolPortalResourceCollection +from ._models_py3 import DevToolPortalResourceRequests +from ._models_py3 import DevToolPortalSsoProperties +from ._models_py3 import DiagnosticParameters +from ._models_py3 import Error +from ._models_py3 import ExecAction +from ._models_py3 import GatewayApiMetadataProperties +from ._models_py3 import GatewayApiRoute +from ._models_py3 import GatewayCorsProperties +from ._models_py3 import GatewayCustomDomainProperties +from ._models_py3 import GatewayCustomDomainResource +from ._models_py3 import GatewayCustomDomainResourceCollection +from ._models_py3 import GatewayInstance +from ._models_py3 import GatewayOperatorProperties +from ._models_py3 import GatewayOperatorResourceRequests +from ._models_py3 import GatewayProperties +from ._models_py3 import GatewayPropertiesEnvironmentVariables +from ._models_py3 import GatewayResource +from ._models_py3 import GatewayResourceCollection +from ._models_py3 import GatewayResourceRequests +from ._models_py3 import GatewayRouteConfigOpenApiProperties +from ._models_py3 import GatewayRouteConfigProperties +from ._models_py3 import GatewayRouteConfigResource +from ._models_py3 import GatewayRouteConfigResourceCollection +from ._models_py3 import GitPatternRepository +from ._models_py3 import HTTPGetAction +from ._models_py3 import ImageRegistryCredential +from ._models_py3 import IngressConfig +from ._models_py3 import IngressSettings +from ._models_py3 import IngressSettingsClientAuth +from ._models_py3 import JarUploadedUserSourceInfo +from ._models_py3 import KeyVaultCertificateProperties +from ._models_py3 import LoadedCertificate +from ._models_py3 import LogFileUrlResponse +from ._models_py3 import LogSpecification +from ._models_py3 import ManagedIdentityProperties +from ._models_py3 import MarketplaceResource +from ._models_py3 import MetricDimension +from ._models_py3 import MetricSpecification +from ._models_py3 import MonitoringSettingProperties +from ._models_py3 import MonitoringSettingResource +from ._models_py3 import NameAvailability +from ._models_py3 import NameAvailabilityParameters +from ._models_py3 import NetCoreZipUploadedUserSourceInfo +from ._models_py3 import NetworkProfile +from ._models_py3 import NetworkProfileOutboundIPs +from ._models_py3 import OperationDetail +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationProperties +from ._models_py3 import PersistentDisk +from ._models_py3 import PredefinedAcceleratorProperties +from ._models_py3 import PredefinedAcceleratorResource +from ._models_py3 import PredefinedAcceleratorResourceCollection +from ._models_py3 import Probe +from ._models_py3 import ProbeAction +from ._models_py3 import ProxyResource +from ._models_py3 import RegenerateTestKeyRequestPayload +from ._models_py3 import RemoteDebugging +from ._models_py3 import RemoteDebuggingPayload +from ._models_py3 import RequiredTraffic +from ._models_py3 import Resource +from ._models_py3 import ResourceRequests +from ._models_py3 import ResourceSku +from ._models_py3 import ResourceSkuCapabilities +from ._models_py3 import ResourceSkuCollection +from ._models_py3 import ResourceSkuLocationInfo +from ._models_py3 import ResourceSkuRestrictionInfo +from ._models_py3 import ResourceSkuRestrictions +from ._models_py3 import ResourceSkuZoneDetails +from ._models_py3 import ResourceUploadDefinition +from ._models_py3 import ServiceRegistryInstance +from ._models_py3 import ServiceRegistryProperties +from ._models_py3 import ServiceRegistryResource +from ._models_py3 import ServiceRegistryResourceCollection +from ._models_py3 import ServiceRegistryResourceRequests +from ._models_py3 import ServiceResource +from ._models_py3 import ServiceResourceList +from ._models_py3 import ServiceSpecification +from ._models_py3 import ServiceVNetAddons +from ._models_py3 import Sku +from ._models_py3 import SkuCapacity +from ._models_py3 import SourceUploadedUserSourceInfo +from ._models_py3 import SsoProperties +from ._models_py3 import StackProperties +from ._models_py3 import StorageAccount +from ._models_py3 import StorageProperties +from ._models_py3 import StorageResource +from ._models_py3 import StorageResourceCollection +from ._models_py3 import SupportedBuildpackResource +from ._models_py3 import SupportedBuildpackResourceProperties +from ._models_py3 import SupportedBuildpacksCollection +from ._models_py3 import SupportedRuntimeVersion +from ._models_py3 import SupportedStackResource +from ._models_py3 import SupportedStackResourceProperties +from ._models_py3 import SupportedStacksCollection +from ._models_py3 import SystemData +from ._models_py3 import TCPSocketAction +from ._models_py3 import TemporaryDisk +from ._models_py3 import TestKeys +from ._models_py3 import TrackedResource +from ._models_py3 import TriggeredBuildResult +from ._models_py3 import UploadedUserSourceInfo +from ._models_py3 import UserAssignedManagedIdentity +from ._models_py3 import UserSourceInfo +from ._models_py3 import ValidationMessages + +from ._app_platform_management_client_enums import ActionType +from ._app_platform_management_client_enums import ApiPortalProvisioningState +from ._app_platform_management_client_enums import ApmType +from ._app_platform_management_client_enums import AppResourceProvisioningState +from ._app_platform_management_client_enums import ApplicationAcceleratorProvisioningState +from ._app_platform_management_client_enums import ApplicationLiveViewProvisioningState +from ._app_platform_management_client_enums import BackendProtocol +from ._app_platform_management_client_enums import BindingType +from ._app_platform_management_client_enums import BuildProvisioningState +from ._app_platform_management_client_enums import BuildResultProvisioningState +from ._app_platform_management_client_enums import BuildServiceProvisioningState +from ._app_platform_management_client_enums import BuilderProvisioningState +from ._app_platform_management_client_enums import BuildpackBindingProvisioningState +from ._app_platform_management_client_enums import CertificateResourceProvisioningState +from ._app_platform_management_client_enums import ConfigServerState +from ._app_platform_management_client_enums import ConfigurationServiceProvisioningState +from ._app_platform_management_client_enums import CreatedByType +from ._app_platform_management_client_enums import CustomDomainResourceProvisioningState +from ._app_platform_management_client_enums import CustomizedAcceleratorProvisioningState +from ._app_platform_management_client_enums import CustomizedAcceleratorValidateResultState +from ._app_platform_management_client_enums import DeploymentResourceProvisioningState +from ._app_platform_management_client_enums import DeploymentResourceStatus +from ._app_platform_management_client_enums import DevToolPortalFeatureState +from ._app_platform_management_client_enums import DevToolPortalProvisioningState +from ._app_platform_management_client_enums import GatewayProvisioningState +from ._app_platform_management_client_enums import GatewayRouteConfigProtocol +from ._app_platform_management_client_enums import HTTPSchemeType +from ._app_platform_management_client_enums import KPackBuildStageProvisioningState +from ._app_platform_management_client_enums import LastModifiedByType +from ._app_platform_management_client_enums import ManagedIdentityType +from ._app_platform_management_client_enums import MonitoringSettingState +from ._app_platform_management_client_enums import PowerState +from ._app_platform_management_client_enums import PredefinedAcceleratorProvisioningState +from ._app_platform_management_client_enums import PredefinedAcceleratorState +from ._app_platform_management_client_enums import ProbeActionType +from ._app_platform_management_client_enums import ProvisioningState +from ._app_platform_management_client_enums import ResourceSkuRestrictionsReasonCode +from ._app_platform_management_client_enums import ResourceSkuRestrictionsType +from ._app_platform_management_client_enums import ServiceRegistryProvisioningState +from ._app_platform_management_client_enums import SessionAffinity +from ._app_platform_management_client_enums import SkuScaleType +from ._app_platform_management_client_enums import StorageType +from ._app_platform_management_client_enums import SupportedRuntimePlatform +from ._app_platform_management_client_enums import SupportedRuntimeValue +from ._app_platform_management_client_enums import TestKeyType +from ._app_platform_management_client_enums import TrafficDirection +from ._app_platform_management_client_enums import Type +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__ = [ + "AcceleratorAuthSetting", + "AcceleratorBasicAuthSetting", + "AcceleratorGitRepository", + "AcceleratorPublicSetting", + "AcceleratorSshSetting", + "ActiveDeploymentCollection", + "ApiPortalCustomDomainProperties", + "ApiPortalCustomDomainResource", + "ApiPortalCustomDomainResourceCollection", + "ApiPortalInstance", + "ApiPortalProperties", + "ApiPortalResource", + "ApiPortalResourceCollection", + "ApiPortalResourceRequests", + "AppResource", + "AppResourceCollection", + "AppResourceProperties", + "AppVNetAddons", + "ApplicationAcceleratorComponent", + "ApplicationAcceleratorInstance", + "ApplicationAcceleratorProperties", + "ApplicationAcceleratorResource", + "ApplicationAcceleratorResourceCollection", + "ApplicationAcceleratorResourceRequests", + "ApplicationInsightsAgentVersions", + "ApplicationLiveViewComponent", + "ApplicationLiveViewInstance", + "ApplicationLiveViewProperties", + "ApplicationLiveViewResource", + "ApplicationLiveViewResourceCollection", + "ApplicationLiveViewResourceRequests", + "AvailableOperations", + "AvailableRuntimeVersions", + "AzureFileVolume", + "BindingResource", + "BindingResourceCollection", + "BindingResourceProperties", + "Build", + "BuildCollection", + "BuildProperties", + "BuildResourceRequests", + "BuildResult", + "BuildResultCollection", + "BuildResultLog", + "BuildResultProperties", + "BuildResultUserSourceInfo", + "BuildService", + "BuildServiceAgentPoolProperties", + "BuildServiceAgentPoolResource", + "BuildServiceAgentPoolResourceCollection", + "BuildServiceAgentPoolSizeProperties", + "BuildServiceCollection", + "BuildServiceProperties", + "BuildServicePropertiesResourceRequests", + "BuildStageProperties", + "BuilderProperties", + "BuilderResource", + "BuilderResourceCollection", + "BuildpackBindingLaunchProperties", + "BuildpackBindingProperties", + "BuildpackBindingResource", + "BuildpackBindingResourceCollection", + "BuildpackProperties", + "BuildpacksGroupProperties", + "CertificateProperties", + "CertificateResource", + "CertificateResourceCollection", + "CloudErrorBody", + "ClusterResourceProperties", + "ConfigServerGitProperty", + "ConfigServerProperties", + "ConfigServerResource", + "ConfigServerSettings", + "ConfigServerSettingsErrorRecord", + "ConfigServerSettingsValidateResult", + "ConfigurationServiceGitProperty", + "ConfigurationServiceGitPropertyValidateResult", + "ConfigurationServiceGitRepository", + "ConfigurationServiceInstance", + "ConfigurationServiceProperties", + "ConfigurationServiceResource", + "ConfigurationServiceResourceCollection", + "ConfigurationServiceResourceRequests", + "ConfigurationServiceSettings", + "ConfigurationServiceSettingsValidateResult", + "ContainerProbeSettings", + "ContentCertificateProperties", + "CustomContainer", + "CustomContainerUserSourceInfo", + "CustomDomainProperties", + "CustomDomainResource", + "CustomDomainResourceCollection", + "CustomDomainValidatePayload", + "CustomDomainValidateResult", + "CustomPersistentDiskProperties", + "CustomPersistentDiskResource", + "CustomizedAcceleratorProperties", + "CustomizedAcceleratorResource", + "CustomizedAcceleratorResourceCollection", + "CustomizedAcceleratorValidateResult", + "DeploymentInstance", + "DeploymentList", + "DeploymentResource", + "DeploymentResourceCollection", + "DeploymentResourceProperties", + "DeploymentSettings", + "DevToolPortalFeatureDetail", + "DevToolPortalFeatureSettings", + "DevToolPortalInstance", + "DevToolPortalProperties", + "DevToolPortalResource", + "DevToolPortalResourceCollection", + "DevToolPortalResourceRequests", + "DevToolPortalSsoProperties", + "DiagnosticParameters", + "Error", + "ExecAction", + "GatewayApiMetadataProperties", + "GatewayApiRoute", + "GatewayCorsProperties", + "GatewayCustomDomainProperties", + "GatewayCustomDomainResource", + "GatewayCustomDomainResourceCollection", + "GatewayInstance", + "GatewayOperatorProperties", + "GatewayOperatorResourceRequests", + "GatewayProperties", + "GatewayPropertiesEnvironmentVariables", + "GatewayResource", + "GatewayResourceCollection", + "GatewayResourceRequests", + "GatewayRouteConfigOpenApiProperties", + "GatewayRouteConfigProperties", + "GatewayRouteConfigResource", + "GatewayRouteConfigResourceCollection", + "GitPatternRepository", + "HTTPGetAction", + "ImageRegistryCredential", + "IngressConfig", + "IngressSettings", + "IngressSettingsClientAuth", + "JarUploadedUserSourceInfo", + "KeyVaultCertificateProperties", + "LoadedCertificate", + "LogFileUrlResponse", + "LogSpecification", + "ManagedIdentityProperties", + "MarketplaceResource", + "MetricDimension", + "MetricSpecification", + "MonitoringSettingProperties", + "MonitoringSettingResource", + "NameAvailability", + "NameAvailabilityParameters", + "NetCoreZipUploadedUserSourceInfo", + "NetworkProfile", + "NetworkProfileOutboundIPs", + "OperationDetail", + "OperationDisplay", + "OperationProperties", + "PersistentDisk", + "PredefinedAcceleratorProperties", + "PredefinedAcceleratorResource", + "PredefinedAcceleratorResourceCollection", + "Probe", + "ProbeAction", + "ProxyResource", + "RegenerateTestKeyRequestPayload", + "RemoteDebugging", + "RemoteDebuggingPayload", + "RequiredTraffic", + "Resource", + "ResourceRequests", + "ResourceSku", + "ResourceSkuCapabilities", + "ResourceSkuCollection", + "ResourceSkuLocationInfo", + "ResourceSkuRestrictionInfo", + "ResourceSkuRestrictions", + "ResourceSkuZoneDetails", + "ResourceUploadDefinition", + "ServiceRegistryInstance", + "ServiceRegistryProperties", + "ServiceRegistryResource", + "ServiceRegistryResourceCollection", + "ServiceRegistryResourceRequests", + "ServiceResource", + "ServiceResourceList", + "ServiceSpecification", + "ServiceVNetAddons", + "Sku", + "SkuCapacity", + "SourceUploadedUserSourceInfo", + "SsoProperties", + "StackProperties", + "StorageAccount", + "StorageProperties", + "StorageResource", + "StorageResourceCollection", + "SupportedBuildpackResource", + "SupportedBuildpackResourceProperties", + "SupportedBuildpacksCollection", + "SupportedRuntimeVersion", + "SupportedStackResource", + "SupportedStackResourceProperties", + "SupportedStacksCollection", + "SystemData", + "TCPSocketAction", + "TemporaryDisk", + "TestKeys", + "TrackedResource", + "TriggeredBuildResult", + "UploadedUserSourceInfo", + "UserAssignedManagedIdentity", + "UserSourceInfo", + "ValidationMessages", + "ActionType", + "ApiPortalProvisioningState", + "ApmType", + "AppResourceProvisioningState", + "ApplicationAcceleratorProvisioningState", + "ApplicationLiveViewProvisioningState", + "BackendProtocol", + "BindingType", + "BuildProvisioningState", + "BuildResultProvisioningState", + "BuildServiceProvisioningState", + "BuilderProvisioningState", + "BuildpackBindingProvisioningState", + "CertificateResourceProvisioningState", + "ConfigServerState", + "ConfigurationServiceProvisioningState", + "CreatedByType", + "CustomDomainResourceProvisioningState", + "CustomizedAcceleratorProvisioningState", + "CustomizedAcceleratorValidateResultState", + "DeploymentResourceProvisioningState", + "DeploymentResourceStatus", + "DevToolPortalFeatureState", + "DevToolPortalProvisioningState", + "GatewayProvisioningState", + "GatewayRouteConfigProtocol", + "HTTPSchemeType", + "KPackBuildStageProvisioningState", + "LastModifiedByType", + "ManagedIdentityType", + "MonitoringSettingState", + "PowerState", + "PredefinedAcceleratorProvisioningState", + "PredefinedAcceleratorState", + "ProbeActionType", + "ProvisioningState", + "ResourceSkuRestrictionsReasonCode", + "ResourceSkuRestrictionsType", + "ServiceRegistryProvisioningState", + "SessionAffinity", + "SkuScaleType", + "StorageType", + "SupportedRuntimePlatform", + "SupportedRuntimeValue", + "TestKeyType", + "TrafficDirection", + "Type", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/models/_app_platform_management_client_enums.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/models/_app_platform_management_client_enums.py new file mode 100644 index 000000000000..9c426cdb4712 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/models/_app_platform_management_client_enums.py @@ -0,0 +1,439 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" + + INTERNAL = "Internal" + + +class ApiPortalProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the API portal.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class ApmType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of application performance monitoring.""" + + APPLICATION_INSIGHTS = "ApplicationInsights" + APP_DYNAMICS = "AppDynamics" + DYNATRACE = "Dynatrace" + NEW_RELIC = "NewRelic" + ELASTIC_APM = "ElasticAPM" + + +class ApplicationAcceleratorProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the application accelerator.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class ApplicationLiveViewProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Application Live View.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + CANCELED = "Canceled" + + +class AppResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the App.""" + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + + +class BackendProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """How ingress should communicate with this app backend service.""" + + GRPC = "GRPC" + DEFAULT = "Default" + + +class BindingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Buildpack Binding Type.""" + + APPLICATION_INSIGHTS = "ApplicationInsights" + APACHE_SKY_WALKING = "ApacheSkyWalking" + APP_DYNAMICS = "AppDynamics" + DYNATRACE = "Dynatrace" + NEW_RELIC = "NewRelic" + ELASTIC_APM = "ElasticAPM" + CA_CERTIFICATES = "CACertificates" + + +class BuilderProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Builder provision status.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class BuildpackBindingProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Buildpack Binding.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class BuildProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class BuildResultProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" + + QUEUING = "Queuing" + BUILDING = "Building" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class BuildServiceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the KPack build result.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class CertificateResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Certificate.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class ConfigServerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the config server.""" + + NOT_AVAILABLE = "NotAvailable" + DELETED = "Deleted" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + + +class ConfigurationServiceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Application Configuration Service.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class CustomDomainResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Domain.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class CustomizedAcceleratorProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the customized accelerator.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class CustomizedAcceleratorValidateResultState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the customized accelerator validation result.""" + + #: Customized accelerator properties are valid. + VALID = "Valid" + #: Customized accelerator properties are invalid. + INVALID = "Invalid" + + +class DeploymentResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Deployment.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + + +class DeploymentResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the Deployment.""" + + STOPPED = "Stopped" + RUNNING = "Running" + + +class DevToolPortalFeatureState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the plugin.""" + + #: Enable the plugin in Dev Tool Portal. + ENABLED = "Enabled" + #: Disable the plugin in Dev Tool Portal. + DISABLED = "Disabled" + + +class DevToolPortalProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Dev Tool Portal.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + CANCELED = "Canceled" + + +class GatewayProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Spring Cloud Gateway.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class GatewayRouteConfigProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Protocol of routed Azure Spring Apps applications.""" + + HTTP = "HTTP" + HTTPS = "HTTPS" + + +class HTTPSchemeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scheme to use for connecting to the host. Defaults to HTTP. + + Possible enum values: + + + * ``"HTTP"`` means that the scheme used will be http:// + * ``"HTTPS"`` means that the scheme used will be https://. + """ + + HTTP = "HTTP" + HTTPS = "HTTPS" + + +class KPackBuildStageProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of this build stage resource.""" + + NOT_STARTED = "NotStarted" + RUNNING = "Running" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the managed identity.""" + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + + +class MonitoringSettingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Monitoring Setting.""" + + NOT_AVAILABLE = "NotAvailable" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + + +class PowerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Power state of the Service.""" + + RUNNING = "Running" + STOPPED = "Stopped" + + +class PredefinedAcceleratorProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the predefined accelerator.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + + +class PredefinedAcceleratorState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the predefined accelerator.""" + + #: Enable the predefined accelerator. + ENABLED = "Enabled" + #: Disable the predefined accelerator. + DISABLED = "Disabled" + + +class ProbeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the action to take to perform the health check.""" + + HTTP_GET_ACTION = "HTTPGetAction" + TCP_SOCKET_ACTION = "TCPSocketAction" + EXEC_ACTION = "ExecAction" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Service.""" + + CREATING = "Creating" + UPDATING = "Updating" + STARTING = "Starting" + STOPPING = "Stopping" + DELETING = "Deleting" + DELETED = "Deleted" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + MOVING = "Moving" + MOVED = "Moved" + MOVE_FAILED = "MoveFailed" + + +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the reason for restriction. Possible values include: 'QuotaId', + 'NotAvailableForSubscription'. + """ + + QUOTA_ID = "QuotaId" + NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + + +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the type of restrictions. Possible values include: 'Location', 'Zone'.""" + + LOCATION = "Location" + ZONE = "Zone" + + +class ServiceRegistryProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the Service Registry.""" + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + + +class SessionAffinity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the affinity, set this to Cookie to enable session affinity.""" + + COOKIE = "Cookie" + NONE = "None" + + +class SkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type of the scale.""" + + NONE = "None" + MANUAL = "Manual" + AUTOMATIC = "Automatic" + + +class StorageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the storage.""" + + STORAGE_ACCOUNT = "StorageAccount" + + +class SupportedRuntimePlatform(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The platform of this runtime version (possible values: "Java" or ".NET").""" + + JAVA = "Java" + _NET_CORE = ".NET Core" + + +class SupportedRuntimeValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The raw value which could be passed to deployment CRUD operations.""" + + JAVA8 = "Java_8" + JAVA11 = "Java_11" + JAVA17 = "Java_17" + NET_CORE31 = "NetCore_31" + + +class TestKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the test key.""" + + PRIMARY = "Primary" + SECONDARY = "Secondary" + + +class TrafficDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The direction of required traffic.""" + + INBOUND = "Inbound" + OUTBOUND = "Outbound" + + +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the underlying resource to mount as a persistent disk.""" + + AZURE_FILE_VOLUME = "AzureFileVolume" diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/models/_models_py3.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/models/_models_py3.py new file mode 100644 index 000000000000..53f8307bf0fe --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/models/_models_py3.py @@ -0,0 +1,9166 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object + + +class AcceleratorAuthSetting(_serialization.Model): + """Auth setting payload. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AcceleratorBasicAuthSetting, AcceleratorPublicSetting, AcceleratorSshSetting + + All required parameters must be populated in order to send to Azure. + + :ivar auth_type: The type of the auth setting. Required. + :vartype auth_type: str + """ + + _validation = { + "auth_type": {"required": True}, + } + + _attribute_map = { + "auth_type": {"key": "authType", "type": "str"}, + } + + _subtype_map = { + "auth_type": { + "BasicAuth": "AcceleratorBasicAuthSetting", + "Public": "AcceleratorPublicSetting", + "SSH": "AcceleratorSshSetting", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.auth_type = None # type: Optional[str] + + +class AcceleratorBasicAuthSetting(AcceleratorAuthSetting): + """Auth setting for basic auth. + + All required parameters must be populated in order to send to Azure. + + :ivar auth_type: The type of the auth setting. Required. + :vartype auth_type: str + :ivar username: Username of git repository basic auth. Required. + :vartype username: str + :ivar password: Password of git repository basic auth. + :vartype password: str + """ + + _validation = { + "auth_type": {"required": True}, + "username": {"required": True}, + } + + _attribute_map = { + "auth_type": {"key": "authType", "type": "str"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + } + + def __init__(self, *, username: str, password: Optional[str] = None, **kwargs): + """ + :keyword username: Username of git repository basic auth. Required. + :paramtype username: str + :keyword password: Password of git repository basic auth. + :paramtype password: str + """ + super().__init__(**kwargs) + self.auth_type = "BasicAuth" # type: str + self.username = username + self.password = password + + +class AcceleratorGitRepository(_serialization.Model): + """AcceleratorGitRepository. + + All required parameters must be populated in order to send to Azure. + + :ivar url: Git repository URL for the accelerator. Required. + :vartype url: str + :ivar interval_in_seconds: Interval for checking for updates to Git or image repository. + :vartype interval_in_seconds: int + :ivar branch: Git repository branch to be used. + :vartype branch: str + :ivar commit: Git repository commit to be used. + :vartype commit: str + :ivar git_tag: Git repository tag to be used. + :vartype git_tag: str + :ivar auth_setting: Properties of the auth setting payload. Required. + :vartype auth_setting: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.AcceleratorAuthSetting + """ + + _validation = { + "url": {"required": True}, + "auth_setting": {"required": True}, + } + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "interval_in_seconds": {"key": "intervalInSeconds", "type": "int"}, + "branch": {"key": "branch", "type": "str"}, + "commit": {"key": "commit", "type": "str"}, + "git_tag": {"key": "gitTag", "type": "str"}, + "auth_setting": {"key": "authSetting", "type": "AcceleratorAuthSetting"}, + } + + def __init__( + self, + *, + url: str, + auth_setting: "_models.AcceleratorAuthSetting", + interval_in_seconds: Optional[int] = None, + branch: Optional[str] = None, + commit: Optional[str] = None, + git_tag: Optional[str] = None, + **kwargs + ): + """ + :keyword url: Git repository URL for the accelerator. Required. + :paramtype url: str + :keyword interval_in_seconds: Interval for checking for updates to Git or image repository. + :paramtype interval_in_seconds: int + :keyword branch: Git repository branch to be used. + :paramtype branch: str + :keyword commit: Git repository commit to be used. + :paramtype commit: str + :keyword git_tag: Git repository tag to be used. + :paramtype git_tag: str + :keyword auth_setting: Properties of the auth setting payload. Required. + :paramtype auth_setting: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.AcceleratorAuthSetting + """ + super().__init__(**kwargs) + self.url = url + self.interval_in_seconds = interval_in_seconds + self.branch = branch + self.commit = commit + self.git_tag = git_tag + self.auth_setting = auth_setting + + +class AcceleratorPublicSetting(AcceleratorAuthSetting): + """Auth setting for public url. + + All required parameters must be populated in order to send to Azure. + + :ivar auth_type: The type of the auth setting. Required. + :vartype auth_type: str + """ + + _validation = { + "auth_type": {"required": True}, + } + + _attribute_map = { + "auth_type": {"key": "authType", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.auth_type = "Public" # type: str + + +class AcceleratorSshSetting(AcceleratorAuthSetting): + """Auth setting for SSH auth. + + All required parameters must be populated in order to send to Azure. + + :ivar auth_type: The type of the auth setting. Required. + :vartype auth_type: str + :ivar host_key: Public SSH Key of git repository. + :vartype host_key: str + :ivar host_key_algorithm: SSH Key algorithm of git repository. + :vartype host_key_algorithm: str + :ivar private_key: Private SSH Key algorithm of git repository. + :vartype private_key: str + """ + + _validation = { + "auth_type": {"required": True}, + } + + _attribute_map = { + "auth_type": {"key": "authType", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + } + + def __init__( + self, + *, + host_key: Optional[str] = None, + host_key_algorithm: Optional[str] = None, + private_key: Optional[str] = None, + **kwargs + ): + """ + :keyword host_key: Public SSH Key of git repository. + :paramtype host_key: str + :keyword host_key_algorithm: SSH Key algorithm of git repository. + :paramtype host_key_algorithm: str + :keyword private_key: Private SSH Key algorithm of git repository. + :paramtype private_key: str + """ + super().__init__(**kwargs) + self.auth_type = "SSH" # type: str + self.host_key = host_key + self.host_key_algorithm = host_key_algorithm + self.private_key = private_key + + +class ActiveDeploymentCollection(_serialization.Model): + """Object that includes an array of Deployment resource name and set them as active. + + :ivar active_deployment_names: Collection of Deployment name. + :vartype active_deployment_names: list[str] + """ + + _attribute_map = { + "active_deployment_names": {"key": "activeDeploymentNames", "type": "[str]"}, + } + + def __init__(self, *, active_deployment_names: Optional[List[str]] = None, **kwargs): + """ + :keyword active_deployment_names: Collection of Deployment name. + :paramtype active_deployment_names: list[str] + """ + super().__init__(**kwargs) + self.active_deployment_names = active_deployment_names + + +class ApiPortalCustomDomainProperties(_serialization.Model): + """The properties of custom domain for API portal. + + :ivar thumbprint: The thumbprint of bound certificate. + :vartype thumbprint: str + """ + + _attribute_map = { + "thumbprint": {"key": "thumbprint", "type": "str"}, + } + + def __init__(self, *, thumbprint: Optional[str] = None, **kwargs): + """ + :keyword thumbprint: The thumbprint of bound certificate. + :paramtype thumbprint: str + """ + super().__init__(**kwargs) + self.thumbprint = thumbprint + + +class Resource(_serialization.Model): + """The core properties of ARM resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class ProxyResource(Resource): + """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + + +class ApiPortalCustomDomainResource(ProxyResource): + """Custom domain of the API portal. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: The properties of custom domain for API portal. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainProperties + """ + + _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": "ApiPortalCustomDomainProperties"}, + } + + def __init__(self, *, properties: Optional["_models.ApiPortalCustomDomainProperties"] = None, **kwargs): + """ + :keyword properties: The properties of custom domain for API portal. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ApiPortalCustomDomainResourceCollection(_serialization.Model): + """Object that includes an array of API portal custom domain resources and a possible link for next set. + + :ivar value: Collection of API portal custom domain resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ApiPortalCustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ApiPortalCustomDomainResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of API portal custom domain resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApiPortalInstance(_serialization.Model): + """Collection of instances belong to the API portal. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the API portal instance. + :vartype name: str + :ivar status: Status of the API portal instance. + :vartype status: str + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + + +class ApiPortalProperties(_serialization.Model): + """API portal properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the API portal. Known values are: "Creating", "Updating", + "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalProvisioningState + :ivar public: Indicates whether the API portal exposes endpoint. + :vartype public: bool + :ivar url: URL of the API portal, exposed when 'public' is true. + :vartype url: str + :ivar https_only: Indicate if only https is allowed. + :vartype https_only: bool + :ivar gateway_ids: The array of resource Ids of gateway to integrate with API portal. + :vartype gateway_ids: list[str] + :ivar source_urls: Collection of OpenAPI source URL locations. + :vartype source_urls: list[str] + :ivar sso_properties: Single sign-on related configuration. + :vartype sso_properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SsoProperties + :ivar resource_requests: The requested resource quantity for required CPU and Memory. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResourceRequests + :ivar instances: Collection of instances belong to API portal. + :vartype instances: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalInstance] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "url": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "gateway_ids": {"key": "gatewayIds", "type": "[str]"}, + "source_urls": {"key": "sourceUrls", "type": "[str]"}, + "sso_properties": {"key": "ssoProperties", "type": "SsoProperties"}, + "resource_requests": {"key": "resourceRequests", "type": "ApiPortalResourceRequests"}, + "instances": {"key": "instances", "type": "[ApiPortalInstance]"}, + } + + def __init__( + self, + *, + public: bool = False, + https_only: bool = False, + gateway_ids: Optional[List[str]] = None, + source_urls: Optional[List[str]] = None, + sso_properties: Optional["_models.SsoProperties"] = None, + **kwargs + ): + """ + :keyword public: Indicates whether the API portal exposes endpoint. + :paramtype public: bool + :keyword https_only: Indicate if only https is allowed. + :paramtype https_only: bool + :keyword gateway_ids: The array of resource Ids of gateway to integrate with API portal. + :paramtype gateway_ids: list[str] + :keyword source_urls: Collection of OpenAPI source URL locations. + :paramtype source_urls: list[str] + :keyword sso_properties: Single sign-on related configuration. + :paramtype sso_properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SsoProperties + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.public = public + self.url = None + self.https_only = https_only + self.gateway_ids = gateway_ids + self.source_urls = source_urls + self.sso_properties = sso_properties + self.resource_requests = None + self.instances = None + + +class ApiPortalResource(ProxyResource): + """API portal resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: API portal properties payload. + :vartype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalProperties + :ivar sku: Sku of the API portal resource. + :vartype sku: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Sku + """ + + _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": "ApiPortalProperties"}, + "sku": {"key": "sku", "type": "Sku"}, + } + + def __init__( + self, + *, + properties: Optional["_models.ApiPortalProperties"] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword properties: API portal properties payload. + :paramtype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalProperties + :keyword sku: Sku of the API portal resource. + :paramtype sku: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Sku + """ + super().__init__(**kwargs) + self.properties = properties + self.sku = sku + + +class ApiPortalResourceCollection(_serialization.Model): + """Object that includes an array of API portal resources and a possible link for next set. + + :ivar value: Collection of API portal resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ApiPortalResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.ApiPortalResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of API portal resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApiPortalResourceRequests(_serialization.Model): + """Resource requests of the API portal. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: Cpu allocated to each API portal instance. + :vartype cpu: str + :ivar memory: Memory allocated to each API portal instance. + :vartype memory: str + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + } + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.cpu = None + self.memory = None + + +class ApplicationAcceleratorComponent(_serialization.Model): + """ApplicationAcceleratorComponent. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: + :vartype name: str + :ivar resource_requests: + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResourceRequests + :ivar instances: + :vartype instances: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorInstance] + """ + + _validation = { + "name": {"readonly": True}, + "instances": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "ApplicationAcceleratorResourceRequests"}, + "instances": {"key": "instances", "type": "[ApplicationAcceleratorInstance]"}, + } + + def __init__( + self, *, resource_requests: Optional["_models.ApplicationAcceleratorResourceRequests"] = None, **kwargs + ): + """ + :keyword resource_requests: + :paramtype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResourceRequests + """ + super().__init__(**kwargs) + self.name = None + self.resource_requests = resource_requests + self.instances = None + + +class ApplicationAcceleratorInstance(_serialization.Model): + """ApplicationAcceleratorInstance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Application Accelerator instance. + :vartype name: str + :ivar status: Status of the Application Accelerator instance. It can be Pending, Running, + Succeeded, Failed, Unknown. + :vartype status: str + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + + +class ApplicationAcceleratorProperties(_serialization.Model): + """Application accelerator properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the application accelerator. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorProvisioningState + :ivar components: Collection of components belong to application accelerator. + :vartype components: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorComponent] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "components": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "components": {"key": "components", "type": "[ApplicationAcceleratorComponent]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.provisioning_state = None + self.components = None + + +class ApplicationAcceleratorResource(ProxyResource): + """Application accelerator resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Application accelerator properties payload. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorProperties + :ivar sku: Sku of the application accelerator resource. + :vartype sku: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Sku + """ + + _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": "ApplicationAcceleratorProperties"}, + "sku": {"key": "sku", "type": "Sku"}, + } + + def __init__( + self, + *, + properties: Optional["_models.ApplicationAcceleratorProperties"] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword properties: Application accelerator properties payload. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorProperties + :keyword sku: Sku of the application accelerator resource. + :paramtype sku: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Sku + """ + super().__init__(**kwargs) + self.properties = properties + self.sku = sku + + +class ApplicationAcceleratorResourceCollection(_serialization.Model): + """Object that includes an array of application accelerator resources and a possible link for next set. + + :ivar value: Collection of application accelerator resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ApplicationAcceleratorResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ApplicationAcceleratorResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of application accelerator resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationAcceleratorResourceRequests(_serialization.Model): + """ApplicationAcceleratorResourceRequests. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: Cpu allocated to each application accelerator component. 1 core can be represented + by 1 or 1000m. + :vartype cpu: str + :ivar memory: Memory allocated to each application accelerator component. 1 GB can be + represented by 1Gi or 1024Mi. + :vartype memory: str + :ivar instance_count: Instance count of the application accelerator component. + :vartype instance_count: int + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, + } + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.cpu = None + self.memory = None + self.instance_count = None + + +class ApplicationInsightsAgentVersions(_serialization.Model): + """Application Insights agent versions properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar java: Indicates the version of application insight java agent. + :vartype java: str + """ + + _validation = { + "java": {"readonly": True}, + } + + _attribute_map = { + "java": {"key": "java", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.java = None + + +class ApplicationLiveViewComponent(_serialization.Model): + """Application Live View properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the component. + :vartype name: any + :ivar resource_requests: The requested resource quantity for required CPU and Memory. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResourceRequests + :ivar instances: Collection of instances belong to Application Live View. + :vartype instances: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewInstance] + """ + + _validation = { + "name": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "object"}, + "resource_requests": {"key": "resourceRequests", "type": "ApplicationLiveViewResourceRequests"}, + "instances": {"key": "instances", "type": "[ApplicationLiveViewInstance]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.resource_requests = None + self.instances = None + + +class ApplicationLiveViewInstance(_serialization.Model): + """Collection of instances belong to the Application Live View. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Application Live View instance. + :vartype name: str + :ivar status: Status of the Application Live View instance. It can be Pending, Running, + Succeeded, Failed, Unknown. + :vartype status: str + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + + +class ApplicationLiveViewProperties(_serialization.Model): + """Application Live View properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the Application Live View. Known values are: "Creating", + "Updating", "Succeeded", "Failed", "Deleting", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewProvisioningState + :ivar components: Component details of Application Live View. + :vartype components: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewComponent] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "components": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "components": {"key": "components", "type": "[ApplicationLiveViewComponent]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.provisioning_state = None + self.components = None + + +class ApplicationLiveViewResource(ProxyResource): + """Application Live View resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Application Live View properties payload. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewProperties + """ + + _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": "ApplicationLiveViewProperties"}, + } + + def __init__(self, *, properties: Optional["_models.ApplicationLiveViewProperties"] = None, **kwargs): + """ + :keyword properties: Application Live View properties payload. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ApplicationLiveViewResourceCollection(_serialization.Model): + """Object that includes an array of Application Live View resources and a possible link for next set. + + :ivar value: Collection of Application Live View resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ApplicationLiveViewResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ApplicationLiveViewResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of Application Live View resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationLiveViewResourceRequests(_serialization.Model): + """The resource quantity for required CPU and Memory of Application Live View component. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: Cpu quantity allocated to each Application Live View component instance. 1 core can + be represented by 1 or 1000m. + :vartype cpu: str + :ivar memory: Memory quantity allocated to each Application Live View component instance. 1 GB + can be represented by 1Gi or 1024Mi. + :vartype memory: str + :ivar instance_count: Desired instance count of Application Live View component instance. + :vartype instance_count: int + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, + } + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.cpu = None + self.memory = None + self.instance_count = None + + +class AppResource(ProxyResource): + """App resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Properties of the App resource. + :vartype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResourceProperties + :ivar identity: The Managed Identity type of the app resource. + :vartype identity: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ManagedIdentityProperties + :ivar location: The GEO location of the application, always the same with its parent resource. + :vartype location: str + """ + + _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": "AppResourceProperties"}, + "identity": {"key": "identity", "type": "ManagedIdentityProperties"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__( + self, + *, + properties: Optional["_models.AppResourceProperties"] = None, + identity: Optional["_models.ManagedIdentityProperties"] = None, + location: Optional[str] = None, + **kwargs + ): + """ + :keyword properties: Properties of the App resource. + :paramtype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResourceProperties + :keyword identity: The Managed Identity type of the app resource. + :paramtype identity: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ManagedIdentityProperties + :keyword location: The GEO location of the application, always the same with its parent + resource. + :paramtype location: str + """ + super().__init__(**kwargs) + self.properties = properties + self.identity = identity + self.location = location + + +class AppResourceCollection(_serialization.Model): + """Object that includes an array of App resources and a possible link for next set. + + :ivar value: Collection of App resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AppResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.AppResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of App resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AppResourceProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """App resource properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar public: Indicates whether the App exposes public endpoint. + :vartype public: bool + :ivar url: URL of the App. + :vartype url: str + :ivar addon_configs: Collection of addons. + :vartype addon_configs: dict[str, dict[str, JSON]] + :ivar provisioning_state: Provisioning state of the App. Known values are: "Succeeded", + "Failed", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResourceProvisioningState + :ivar fqdn: Fully qualified dns Name. + :vartype fqdn: str + :ivar https_only: Indicate if only https is allowed. + :vartype https_only: bool + :ivar temporary_disk: Temporary disk settings. + :vartype temporary_disk: ~azure.mgmt.appplatform.v2022_11_01_preview.models.TemporaryDisk + :ivar persistent_disk: Persistent disk settings. + :vartype persistent_disk: ~azure.mgmt.appplatform.v2022_11_01_preview.models.PersistentDisk + :ivar custom_persistent_disks: List of custom persistent disks. + :vartype custom_persistent_disks: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomPersistentDiskResource] + :ivar enable_end_to_end_tls: Indicate if end to end TLS is enabled. + :vartype enable_end_to_end_tls: bool + :ivar loaded_certificates: Collection of loaded certificates. + :vartype loaded_certificates: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.LoadedCertificate] + :ivar vnet_addons: Additional App settings in vnet injection instance. + :vartype vnet_addons: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppVNetAddons + :ivar ingress_settings: App ingress settings payload. + :vartype ingress_settings: ~azure.mgmt.appplatform.v2022_11_01_preview.models.IngressSettings + """ + + _validation = { + "url": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "fqdn": {"readonly": True}, + } + + _attribute_map = { + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "addon_configs": {"key": "addonConfigs", "type": "{{object}}"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "fqdn": {"key": "fqdn", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "temporary_disk": {"key": "temporaryDisk", "type": "TemporaryDisk"}, + "persistent_disk": {"key": "persistentDisk", "type": "PersistentDisk"}, + "custom_persistent_disks": {"key": "customPersistentDisks", "type": "[CustomPersistentDiskResource]"}, + "enable_end_to_end_tls": {"key": "enableEndToEndTLS", "type": "bool"}, + "loaded_certificates": {"key": "loadedCertificates", "type": "[LoadedCertificate]"}, + "vnet_addons": {"key": "vnetAddons", "type": "AppVNetAddons"}, + "ingress_settings": {"key": "ingressSettings", "type": "IngressSettings"}, + } + + def __init__( + self, + *, + public: Optional[bool] = None, + addon_configs: Optional[Dict[str, Dict[str, JSON]]] = None, + https_only: bool = False, + temporary_disk: Optional["_models.TemporaryDisk"] = None, + persistent_disk: Optional["_models.PersistentDisk"] = None, + custom_persistent_disks: Optional[List["_models.CustomPersistentDiskResource"]] = None, + enable_end_to_end_tls: bool = False, + loaded_certificates: Optional[List["_models.LoadedCertificate"]] = None, + vnet_addons: Optional["_models.AppVNetAddons"] = None, + ingress_settings: Optional["_models.IngressSettings"] = None, + **kwargs + ): + """ + :keyword public: Indicates whether the App exposes public endpoint. + :paramtype public: bool + :keyword addon_configs: Collection of addons. + :paramtype addon_configs: dict[str, dict[str, JSON]] + :keyword https_only: Indicate if only https is allowed. + :paramtype https_only: bool + :keyword temporary_disk: Temporary disk settings. + :paramtype temporary_disk: ~azure.mgmt.appplatform.v2022_11_01_preview.models.TemporaryDisk + :keyword persistent_disk: Persistent disk settings. + :paramtype persistent_disk: ~azure.mgmt.appplatform.v2022_11_01_preview.models.PersistentDisk + :keyword custom_persistent_disks: List of custom persistent disks. + :paramtype custom_persistent_disks: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomPersistentDiskResource] + :keyword enable_end_to_end_tls: Indicate if end to end TLS is enabled. + :paramtype enable_end_to_end_tls: bool + :keyword loaded_certificates: Collection of loaded certificates. + :paramtype loaded_certificates: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.LoadedCertificate] + :keyword vnet_addons: Additional App settings in vnet injection instance. + :paramtype vnet_addons: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppVNetAddons + :keyword ingress_settings: App ingress settings payload. + :paramtype ingress_settings: ~azure.mgmt.appplatform.v2022_11_01_preview.models.IngressSettings + """ + super().__init__(**kwargs) + self.public = public + self.url = None + self.addon_configs = addon_configs + self.provisioning_state = None + self.fqdn = None + self.https_only = https_only + self.temporary_disk = temporary_disk + self.persistent_disk = persistent_disk + self.custom_persistent_disks = custom_persistent_disks + self.enable_end_to_end_tls = enable_end_to_end_tls + self.loaded_certificates = loaded_certificates + self.vnet_addons = vnet_addons + self.ingress_settings = ingress_settings + + +class AppVNetAddons(_serialization.Model): + """Additional App settings in vnet injection instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar public_endpoint: Indicates whether the App in vnet injection instance exposes endpoint + which could be accessed from internet. + :vartype public_endpoint: bool + :ivar public_endpoint_url: URL of the App in vnet injection instance which could be accessed + from internet. + :vartype public_endpoint_url: str + """ + + _validation = { + "public_endpoint_url": {"readonly": True}, + } + + _attribute_map = { + "public_endpoint": {"key": "publicEndpoint", "type": "bool"}, + "public_endpoint_url": {"key": "publicEndpointUrl", "type": "str"}, + } + + def __init__(self, *, public_endpoint: bool = False, **kwargs): + """ + :keyword public_endpoint: Indicates whether the App in vnet injection instance exposes endpoint + which could be accessed from internet. + :paramtype public_endpoint: bool + """ + super().__init__(**kwargs) + self.public_endpoint = public_endpoint + self.public_endpoint_url = None + + +class AvailableOperations(_serialization.Model): + """Available operations of the service. + + :ivar value: Collection of available operation details. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.OperationDetail] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[OperationDetail]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.OperationDetail"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of available operation details. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.OperationDetail] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AvailableRuntimeVersions(_serialization.Model): + """AvailableRuntimeVersions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of all supported runtime versions. + :vartype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedRuntimeVersion] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SupportedRuntimeVersion]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + + +class CustomPersistentDiskProperties(_serialization.Model): + """Custom persistent disk resource payload. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureFileVolume + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the underlying resource to mount as a persistent disk. Required. + "AzureFileVolume" + :vartype type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.Type + :ivar mount_path: The mount path of the persistent disk. Required. + :vartype mount_path: str + :ivar read_only: Indicates whether the persistent disk is a readOnly one. + :vartype read_only: bool + :ivar mount_options: These are the mount options for a persistent disk. + :vartype mount_options: list[str] + """ + + _validation = { + "type": {"required": True}, + "mount_path": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "mount_path": {"key": "mountPath", "type": "str"}, + "read_only": {"key": "readOnly", "type": "bool"}, + "mount_options": {"key": "mountOptions", "type": "[str]"}, + } + + _subtype_map = {"type": {"AzureFileVolume": "AzureFileVolume"}} + + def __init__( + self, *, mount_path: str, read_only: Optional[bool] = None, mount_options: Optional[List[str]] = None, **kwargs + ): + """ + :keyword mount_path: The mount path of the persistent disk. Required. + :paramtype mount_path: str + :keyword read_only: Indicates whether the persistent disk is a readOnly one. + :paramtype read_only: bool + :keyword mount_options: These are the mount options for a persistent disk. + :paramtype mount_options: list[str] + """ + super().__init__(**kwargs) + self.type = None # type: Optional[str] + self.mount_path = mount_path + self.read_only = read_only + self.mount_options = mount_options + + +class AzureFileVolume(CustomPersistentDiskProperties): + """The properties of the Azure File volume. Azure File shares are mounted as volumes. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the underlying resource to mount as a persistent disk. Required. + "AzureFileVolume" + :vartype type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.Type + :ivar mount_path: The mount path of the persistent disk. Required. + :vartype mount_path: str + :ivar read_only: Indicates whether the persistent disk is a readOnly one. + :vartype read_only: bool + :ivar mount_options: These are the mount options for a persistent disk. + :vartype mount_options: list[str] + :ivar share_name: The share name of the Azure File share. Required. + :vartype share_name: str + """ + + _validation = { + "type": {"required": True}, + "mount_path": {"required": True}, + "share_name": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "mount_path": {"key": "mountPath", "type": "str"}, + "read_only": {"key": "readOnly", "type": "bool"}, + "mount_options": {"key": "mountOptions", "type": "[str]"}, + "share_name": {"key": "shareName", "type": "str"}, + } + + def __init__( + self, + *, + mount_path: str, + share_name: str, + read_only: Optional[bool] = None, + mount_options: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword mount_path: The mount path of the persistent disk. Required. + :paramtype mount_path: str + :keyword read_only: Indicates whether the persistent disk is a readOnly one. + :paramtype read_only: bool + :keyword mount_options: These are the mount options for a persistent disk. + :paramtype mount_options: list[str] + :keyword share_name: The share name of the Azure File share. Required. + :paramtype share_name: str + """ + super().__init__(mount_path=mount_path, read_only=read_only, mount_options=mount_options, **kwargs) + self.type = "AzureFileVolume" # type: str + self.share_name = share_name + + +class BindingResource(ProxyResource): + """Binding resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Properties of the Binding resource. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResourceProperties + """ + + _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": "BindingResourceProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BindingResourceProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the Binding resource. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResourceProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BindingResourceCollection(_serialization.Model): + """Object that includes an array of Binding resources and a possible link for next set. + + :ivar value: Collection of Binding resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[BindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.BindingResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of Binding resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BindingResourceProperties(_serialization.Model): + """Binding resource properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_name: The name of the bound resource. + :vartype resource_name: str + :ivar resource_type: The standard Azure resource type of the bound resource. + :vartype resource_type: str + :ivar resource_id: The Azure resource id of the bound resource. + :vartype resource_id: str + :ivar key: The key of the bound resource. + :vartype key: str + :ivar binding_parameters: Binding parameters of the Binding resource. + :vartype binding_parameters: dict[str, JSON] + :ivar generated_properties: The generated Spring Boot property file for this binding. The + secret will be deducted. + :vartype generated_properties: str + :ivar created_at: Creation time of the Binding resource. + :vartype created_at: str + :ivar updated_at: Update time of the Binding resource. + :vartype updated_at: str + """ + + _validation = { + "resource_name": {"readonly": True}, + "resource_type": {"readonly": True}, + "generated_properties": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + } + + _attribute_map = { + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "binding_parameters": {"key": "bindingParameters", "type": "{object}"}, + "generated_properties": {"key": "generatedProperties", "type": "str"}, + "created_at": {"key": "createdAt", "type": "str"}, + "updated_at": {"key": "updatedAt", "type": "str"}, + } + + def __init__( + self, + *, + resource_id: Optional[str] = None, + key: Optional[str] = None, + binding_parameters: Optional[Dict[str, JSON]] = None, + **kwargs + ): + """ + :keyword resource_id: The Azure resource id of the bound resource. + :paramtype resource_id: str + :keyword key: The key of the bound resource. + :paramtype key: str + :keyword binding_parameters: Binding parameters of the Binding resource. + :paramtype binding_parameters: dict[str, JSON] + """ + super().__init__(**kwargs) + self.resource_name = None + self.resource_type = None + self.resource_id = resource_id + self.key = key + self.binding_parameters = binding_parameters + self.generated_properties = None + self.created_at = None + self.updated_at = None + + +class Build(ProxyResource): + """Build resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Properties of the build resource. + :vartype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildProperties + """ + + _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": "BuildProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BuildProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the build resource. + :paramtype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BuildCollection(_serialization.Model): + """Object that includes an array of Build resources and a possible link for next set. + + :ivar value: Collection of Build resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.Build] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Build]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Build"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: Collection of Build resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.Build] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BuilderProperties(_serialization.Model): + """KPack Builder properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Builder provision status. Known values are: "Creating", "Updating", + "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderProvisioningState + :ivar stack: Builder cluster stack property. + :vartype stack: ~azure.mgmt.appplatform.v2022_11_01_preview.models.StackProperties + :ivar buildpack_groups: Builder buildpack groups. + :vartype buildpack_groups: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpacksGroupProperties] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "stack": {"key": "stack", "type": "StackProperties"}, + "buildpack_groups": {"key": "buildpackGroups", "type": "[BuildpacksGroupProperties]"}, + } + + def __init__( + self, + *, + stack: Optional["_models.StackProperties"] = None, + buildpack_groups: Optional[List["_models.BuildpacksGroupProperties"]] = None, + **kwargs + ): + """ + :keyword stack: Builder cluster stack property. + :paramtype stack: ~azure.mgmt.appplatform.v2022_11_01_preview.models.StackProperties + :keyword buildpack_groups: Builder buildpack groups. + :paramtype buildpack_groups: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpacksGroupProperties] + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.stack = stack + self.buildpack_groups = buildpack_groups + + +class BuilderResource(ProxyResource): + """KPack Builder resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Property of the Builder resource. + :vartype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderProperties + """ + + _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": "BuilderProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BuilderProperties"] = None, **kwargs): + """ + :keyword properties: Property of the Builder resource. + :paramtype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BuilderResourceCollection(_serialization.Model): + """Object that includes an array of Builder resources and a possible link for next set. + + :ivar value: Collection of Builder resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[BuilderResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.BuilderResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of Builder resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BuildpackBindingLaunchProperties(_serialization.Model): + """Buildpack Binding Launch Properties. + + :ivar properties: Non-sensitive properties for launchProperties. + :vartype properties: dict[str, str] + :ivar secrets: Sensitive properties for launchProperties. + :vartype secrets: dict[str, str] + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "{str}"}, + "secrets": {"key": "secrets", "type": "{str}"}, + } + + def __init__( + self, *, properties: Optional[Dict[str, str]] = None, secrets: Optional[Dict[str, str]] = None, **kwargs + ): + """ + :keyword properties: Non-sensitive properties for launchProperties. + :paramtype properties: dict[str, str] + :keyword secrets: Sensitive properties for launchProperties. + :paramtype secrets: dict[str, str] + """ + super().__init__(**kwargs) + self.properties = properties + self.secrets = secrets + + +class BuildpackBindingProperties(_serialization.Model): + """Properties of a buildpack binding. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar binding_type: Buildpack Binding Type. Known values are: "ApplicationInsights", + "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", "ElasticAPM", and "CACertificates". + :vartype binding_type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingType + :ivar provisioning_state: State of the Buildpack Binding. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingProvisioningState + :ivar launch_properties: The object describes the buildpack binding launch properties. + :vartype launch_properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingLaunchProperties + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "binding_type": {"key": "bindingType", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "launch_properties": {"key": "launchProperties", "type": "BuildpackBindingLaunchProperties"}, + } + + def __init__( + self, + *, + binding_type: Optional[Union[str, "_models.BindingType"]] = None, + launch_properties: Optional["_models.BuildpackBindingLaunchProperties"] = None, + **kwargs + ): + """ + :keyword binding_type: Buildpack Binding Type. Known values are: "ApplicationInsights", + "ApacheSkyWalking", "AppDynamics", "Dynatrace", "NewRelic", "ElasticAPM", and "CACertificates". + :paramtype binding_type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingType + :keyword launch_properties: The object describes the buildpack binding launch properties. + :paramtype launch_properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingLaunchProperties + """ + super().__init__(**kwargs) + self.binding_type = binding_type + self.provisioning_state = None + self.launch_properties = launch_properties + + +class BuildpackBindingResource(ProxyResource): + """Buildpack Binding Resource object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Properties of a buildpack binding. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingProperties + """ + + _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": "BuildpackBindingProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BuildpackBindingProperties"] = None, **kwargs): + """ + :keyword properties: Properties of a buildpack binding. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BuildpackBindingResourceCollection(_serialization.Model): + """Object that includes an array of BuildpackBinding resources and a possible link for next set. + + :ivar value: Collection of BuildpackBinding resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[BuildpackBindingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.BuildpackBindingResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of BuildpackBinding resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BuildpackProperties(_serialization.Model): + """Buildpack properties payload. + + :ivar id: Id of the buildpack. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: Id of the buildpack. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class BuildpacksGroupProperties(_serialization.Model): + """Buildpack group properties of the Builder. + + :ivar name: Buildpack group name. + :vartype name: str + :ivar buildpacks: Buildpacks in the buildpack group. + :vartype buildpacks: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackProperties] + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "buildpacks": {"key": "buildpacks", "type": "[BuildpackProperties]"}, + } + + def __init__( + self, *, name: Optional[str] = None, buildpacks: Optional[List["_models.BuildpackProperties"]] = None, **kwargs + ): + """ + :keyword name: Buildpack group name. + :paramtype name: str + :keyword buildpacks: Buildpacks in the buildpack group. + :paramtype buildpacks: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackProperties] + """ + super().__init__(**kwargs) + self.name = name + self.buildpacks = buildpacks + + +class BuildProperties(_serialization.Model): + """Build resource properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar relative_path: The relative path of source code. + :vartype relative_path: str + :ivar builder: The resource id of builder to build the source code. + :vartype builder: str + :ivar agent_pool: The resource id of agent pool. + :vartype agent_pool: str + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildProvisioningState + :ivar env: The environment variables for this build. + :vartype env: dict[str, str] + :ivar triggered_build_result: The build result triggered by this build. + :vartype triggered_build_result: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.TriggeredBuildResult + :ivar resource_requests: The customized build resource for this build. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildResourceRequests + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "triggered_build_result": {"readonly": True}, + } + + _attribute_map = { + "relative_path": {"key": "relativePath", "type": "str"}, + "builder": {"key": "builder", "type": "str"}, + "agent_pool": {"key": "agentPool", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "env": {"key": "env", "type": "{str}"}, + "triggered_build_result": {"key": "triggeredBuildResult", "type": "TriggeredBuildResult"}, + "resource_requests": {"key": "resourceRequests", "type": "BuildResourceRequests"}, + } + + def __init__( + self, + *, + relative_path: Optional[str] = None, + builder: Optional[str] = None, + agent_pool: Optional[str] = None, + env: Optional[Dict[str, str]] = None, + resource_requests: Optional["_models.BuildResourceRequests"] = None, + **kwargs + ): + """ + :keyword relative_path: The relative path of source code. + :paramtype relative_path: str + :keyword builder: The resource id of builder to build the source code. + :paramtype builder: str + :keyword agent_pool: The resource id of agent pool. + :paramtype agent_pool: str + :keyword env: The environment variables for this build. + :paramtype env: dict[str, str] + :keyword resource_requests: The customized build resource for this build. + :paramtype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildResourceRequests + """ + super().__init__(**kwargs) + self.relative_path = relative_path + self.builder = builder + self.agent_pool = agent_pool + self.provisioning_state = None + self.env = env + self.triggered_build_result = None + self.resource_requests = resource_requests + + +class BuildResourceRequests(_serialization.Model): + """Resource request payload of Build Resource. + + :ivar cpu: Optional Cpu allocated to the build resource. 1 core can be represented by 1 or + 1000m. + The default value is 1, this should not exceed build service agent pool cpu size. + :vartype cpu: str + :ivar memory: Optional Memory allocated to the build resource. 1 GB can be represented by 1Gi + or 1024Mi. + The default value is 2Gi, this should not exceed build service agent pool memory size. + :vartype memory: str + """ + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + } + + def __init__(self, *, cpu: str = "1", memory: str = "2Gi", **kwargs): + """ + :keyword cpu: Optional Cpu allocated to the build resource. 1 core can be represented by 1 or + 1000m. + The default value is 1, this should not exceed build service agent pool cpu size. + :paramtype cpu: str + :keyword memory: Optional Memory allocated to the build resource. 1 GB can be represented by + 1Gi or 1024Mi. + The default value is 2Gi, this should not exceed build service agent pool memory size. + :paramtype memory: str + """ + super().__init__(**kwargs) + self.cpu = cpu + self.memory = memory + + +class BuildResult(ProxyResource): + """Build result resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Properties of the build result resource. + :vartype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildResultProperties + """ + + _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": "BuildResultProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BuildResultProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the build result resource. + :paramtype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildResultProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BuildResultCollection(_serialization.Model): + """Object that includes an array of Build result resources and a possible link for next set. + + :ivar value: Collection of Build result resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildResult] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[BuildResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.BuildResult"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of Build result resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildResult] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BuildResultLog(_serialization.Model): + """Build result log resource properties payload. + + :ivar blob_url: The public download URL of this build result log. + :vartype blob_url: str + """ + + _attribute_map = { + "blob_url": {"key": "blobUrl", "type": "str"}, + } + + def __init__(self, *, blob_url: Optional[str] = None, **kwargs): + """ + :keyword blob_url: The public download URL of this build result log. + :paramtype blob_url: str + """ + super().__init__(**kwargs) + self.blob_url = blob_url + + +class BuildResultProperties(_serialization.Model): + """Build result resource properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of this build result. + :vartype name: str + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Queuing", "Building", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildResultProvisioningState + :ivar error: Error when build is failed. + :vartype error: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Error + :ivar build_pod_name: The build pod name which can be used to get the build log streaming. + :vartype build_pod_name: str + :ivar build_stages: All of the build stage (init-container and container) resources in build + pod. + :vartype build_stages: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildStageProperties] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "build_stages": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "build_pod_name": {"key": "buildPodName", "type": "str"}, + "build_stages": {"key": "buildStages", "type": "[BuildStageProperties]"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + error: Optional["_models.Error"] = None, + build_pod_name: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The name of this build result. + :paramtype name: str + :keyword error: Error when build is failed. + :paramtype error: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Error + :keyword build_pod_name: The build pod name which can be used to get the build log streaming. + :paramtype build_pod_name: str + """ + super().__init__(**kwargs) + self.name = name + self.provisioning_state = None + self.error = error + self.build_pod_name = build_pod_name + self.build_stages = None + + +class UserSourceInfo(_serialization.Model): + """Source information for a deployment. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + BuildResultUserSourceInfo, CustomContainerUserSourceInfo, UploadedUserSourceInfo + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the source uploaded. Required. + :vartype type: str + :ivar version: Version of the source. + :vartype version: str + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + _subtype_map = { + "type": { + "BuildResult": "BuildResultUserSourceInfo", + "Container": "CustomContainerUserSourceInfo", + "UploadedUserSourceInfo": "UploadedUserSourceInfo", + } + } + + def __init__(self, *, version: Optional[str] = None, **kwargs): + """ + :keyword version: Version of the source. + :paramtype version: str + """ + super().__init__(**kwargs) + self.type = None # type: Optional[str] + self.version = version + + +class BuildResultUserSourceInfo(UserSourceInfo): + """Reference to a build result. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the source uploaded. Required. + :vartype type: str + :ivar version: Version of the source. + :vartype version: str + :ivar build_result_id: Resource id of an existing succeeded build result under the same Spring + instance. + :vartype build_result_id: str + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "build_result_id": {"key": "buildResultId", "type": "str"}, + } + + def __init__(self, *, version: Optional[str] = None, build_result_id: Optional[str] = None, **kwargs): + """ + :keyword version: Version of the source. + :paramtype version: str + :keyword build_result_id: Resource id of an existing succeeded build result under the same + Spring instance. + :paramtype build_result_id: str + """ + super().__init__(version=version, **kwargs) + self.type = "BuildResult" # type: str + self.build_result_id = build_result_id + + +class BuildService(ProxyResource): + """Build service resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Properties of the build resource. + :vartype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceProperties + """ + + _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": "BuildServiceProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BuildServiceProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the build resource. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BuildServiceAgentPoolProperties(_serialization.Model): + """Build service agent pool properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Provisioning state of the build service agent pool. + :vartype provisioning_state: str + :ivar pool_size: build service agent pool size properties. + :vartype pool_size: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolSizeProperties + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "pool_size": {"key": "poolSize", "type": "BuildServiceAgentPoolSizeProperties"}, + } + + def __init__(self, *, pool_size: Optional["_models.BuildServiceAgentPoolSizeProperties"] = None, **kwargs): + """ + :keyword pool_size: build service agent pool size properties. + :paramtype pool_size: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolSizeProperties + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.pool_size = pool_size + + +class BuildServiceAgentPoolResource(ProxyResource): + """The build service agent pool resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: build service agent pool properties. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolProperties + """ + + _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": "BuildServiceAgentPoolProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BuildServiceAgentPoolProperties"] = None, **kwargs): + """ + :keyword properties: build service agent pool properties. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BuildServiceAgentPoolResourceCollection(_serialization.Model): + """Object that includes an array of build service agent pool resources and a possible link for next set. + + :ivar value: Collection of build service agent pool resource. + :vartype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[BuildServiceAgentPoolResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.BuildServiceAgentPoolResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of build service agent pool resource. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BuildServiceAgentPoolSizeProperties(_serialization.Model): + """Build service agent pool size properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of build service agent pool size. + :vartype name: str + :ivar cpu: The cpu property of build service agent pool size. + :vartype cpu: str + :ivar memory: The memory property of build service agent pool size. + :vartype memory: str + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, **kwargs): + """ + :keyword name: The name of build service agent pool size. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + self.cpu = None + self.memory = None + + +class BuildServiceCollection(_serialization.Model): + """Object that includes an array of Build service resources and a possible link for next set. + + :ivar value: Collection of Build service resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildService] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[BuildService]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.BuildService"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of Build service resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildService] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BuildServiceProperties(_serialization.Model): + """Build service resource properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar k_pack_version: The installed KPack version in this build service. + :vartype k_pack_version: str + :ivar provisioning_state: Provisioning state of the KPack build result. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceProvisioningState + :ivar resource_requests: The runtime resource configuration of this build service. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServicePropertiesResourceRequests + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "k_pack_version": {"key": "kPackVersion", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "BuildServicePropertiesResourceRequests"}, + } + + def __init__( + self, + *, + k_pack_version: Optional[str] = None, + resource_requests: Optional["_models.BuildServicePropertiesResourceRequests"] = None, + **kwargs + ): + """ + :keyword k_pack_version: The installed KPack version in this build service. + :paramtype k_pack_version: str + :keyword resource_requests: The runtime resource configuration of this build service. + :paramtype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServicePropertiesResourceRequests + """ + super().__init__(**kwargs) + self.k_pack_version = k_pack_version + self.provisioning_state = None + self.resource_requests = resource_requests + + +class BuildServicePropertiesResourceRequests(_serialization.Model): + """The runtime resource configuration of this build service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: vCPU allocated to the entire build service node pool. + :vartype cpu: str + :ivar memory: Memory allocated to the entire build service node pool. + :vartype memory: str + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + } + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.cpu = None + self.memory = None + + +class BuildStageProperties(_serialization.Model): + """The build stage (init-container and container) resources in build pod. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of this build stage resource. + :vartype name: str + :ivar status: The provisioning state of this build stage resource. Known values are: + "NotStarted", "Running", "Succeeded", and "Failed". + :vartype status: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.KPackBuildStageProvisioningState + :ivar exit_code: The exit code of this build init container. + :vartype exit_code: str + :ivar reason: The reason of this build init container. + :vartype reason: str + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + "exit_code": {"readonly": True}, + "reason": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "exit_code": {"key": "exitCode", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + self.exit_code = None + self.reason = None + + +class CertificateProperties(_serialization.Model): + """Certificate resource payload. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContentCertificateProperties, KeyVaultCertificateProperties + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the certificate source. Required. + :vartype type: str + :ivar thumbprint: The thumbprint of certificate. + :vartype thumbprint: str + :ivar issuer: The issuer of certificate. + :vartype issuer: str + :ivar issued_date: The issue date of certificate. + :vartype issued_date: str + :ivar expiration_date: The expiration date of certificate. + :vartype expiration_date: str + :ivar activate_date: The activate date of certificate. + :vartype activate_date: str + :ivar subject_name: The subject name of certificate. + :vartype subject_name: str + :ivar dns_names: The domain list of certificate. + :vartype dns_names: list[str] + :ivar provisioning_state: Provisioning state of the Certificate. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResourceProvisioningState + """ + + _validation = { + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + } + + _subtype_map = { + "type": { + "ContentCertificate": "ContentCertificateProperties", + "KeyVaultCertificate": "KeyVaultCertificateProperties", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type = None # type: Optional[str] + self.thumbprint = None + self.issuer = None + self.issued_date = None + self.expiration_date = None + self.activate_date = None + self.subject_name = None + self.dns_names = None + self.provisioning_state = None + + +class CertificateResource(ProxyResource): + """Certificate resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Properties of the certificate resource payload. + :vartype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateProperties + """ + + _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": "CertificateProperties"}, + } + + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the certificate resource payload. + :paramtype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class CertificateResourceCollection(_serialization.Model): + """Collection compose of certificate resources list and a possible link for next page. + + :ivar value: The certificate resources list. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource] + :ivar next_link: The link to next page of certificate list. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[CertificateResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.CertificateResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The certificate resources list. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource] + :keyword next_link: The link to next page of certificate list. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CloudErrorBody(_serialization.Model): + """An error response from the service. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in + error. + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.CloudErrorBody] + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, + **kwargs + ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.CloudErrorBody] + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class ClusterResourceProperties(_serialization.Model): + """Service properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Provisioning state of the Service. Known values are: "Creating", + "Updating", "Starting", "Stopping", "Deleting", "Deleted", "Succeeded", "Failed", "Moving", + "Moved", and "MoveFailed". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ProvisioningState + :ivar network_profile: Network profile of the Service. + :vartype network_profile: ~azure.mgmt.appplatform.v2022_11_01_preview.models.NetworkProfile + :ivar vnet_addons: Additional Service settings in vnet injection instance. + :vartype vnet_addons: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceVNetAddons + :ivar version: Version of the Service. + :vartype version: int + :ivar service_id: ServiceInstanceEntity GUID which uniquely identifies a created resource. + :vartype service_id: str + :ivar power_state: Power state of the Service. Known values are: "Running" and "Stopped". + :vartype power_state: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.PowerState + :ivar zone_redundant: + :vartype zone_redundant: bool + :ivar fqdn: Fully qualified dns name of the service instance. + :vartype fqdn: str + :ivar marketplace_resource: Purchasing 3rd party product of the Service resource. + :vartype marketplace_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.MarketplaceResource + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "service_id": {"readonly": True}, + "power_state": {"readonly": True}, + "fqdn": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "network_profile": {"key": "networkProfile", "type": "NetworkProfile"}, + "vnet_addons": {"key": "vnetAddons", "type": "ServiceVNetAddons"}, + "version": {"key": "version", "type": "int"}, + "service_id": {"key": "serviceId", "type": "str"}, + "power_state": {"key": "powerState", "type": "str"}, + "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, + "fqdn": {"key": "fqdn", "type": "str"}, + "marketplace_resource": {"key": "marketplaceResource", "type": "MarketplaceResource"}, + } + + def __init__( + self, + *, + network_profile: Optional["_models.NetworkProfile"] = None, + vnet_addons: Optional["_models.ServiceVNetAddons"] = None, + zone_redundant: bool = False, + marketplace_resource: Optional["_models.MarketplaceResource"] = None, + **kwargs + ): + """ + :keyword network_profile: Network profile of the Service. + :paramtype network_profile: ~azure.mgmt.appplatform.v2022_11_01_preview.models.NetworkProfile + :keyword vnet_addons: Additional Service settings in vnet injection instance. + :paramtype vnet_addons: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceVNetAddons + :keyword zone_redundant: + :paramtype zone_redundant: bool + :keyword marketplace_resource: Purchasing 3rd party product of the Service resource. + :paramtype marketplace_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.MarketplaceResource + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.network_profile = network_profile + self.vnet_addons = vnet_addons + self.version = None + self.service_id = None + self.power_state = None + self.zone_redundant = zone_redundant + self.fqdn = None + self.marketplace_resource = marketplace_resource + + +class ConfigServerGitProperty(_serialization.Model): + """Property of git. + + All required parameters must be populated in order to send to Azure. + + :ivar repositories: Repositories of git. + :vartype repositories: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.GitPatternRepository] + :ivar uri: URI of the repository. Required. + :vartype uri: str + :ivar label: Label of the repository. + :vartype label: str + :ivar search_paths: Searching path of the repository. + :vartype search_paths: list[str] + :ivar username: Username of git repository basic auth. + :vartype username: str + :ivar password: Password of git repository basic auth. + :vartype password: str + :ivar host_key: Public sshKey of git repository. + :vartype host_key: str + :ivar host_key_algorithm: SshKey algorithm of git repository. + :vartype host_key_algorithm: str + :ivar private_key: Private sshKey algorithm of git repository. + :vartype private_key: str + :ivar strict_host_key_checking: Strict host key checking or not. + :vartype strict_host_key_checking: bool + """ + + _validation = { + "uri": {"required": True}, + } + + _attribute_map = { + "repositories": {"key": "repositories", "type": "[GitPatternRepository]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, + } + + def __init__( + self, + *, + uri: str, + repositories: Optional[List["_models.GitPatternRepository"]] = None, + label: Optional[str] = None, + search_paths: Optional[List[str]] = None, + username: Optional[str] = None, + password: Optional[str] = None, + host_key: Optional[str] = None, + host_key_algorithm: Optional[str] = None, + private_key: Optional[str] = None, + strict_host_key_checking: Optional[bool] = None, + **kwargs + ): + """ + :keyword repositories: Repositories of git. + :paramtype repositories: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.GitPatternRepository] + :keyword uri: URI of the repository. Required. + :paramtype uri: str + :keyword label: Label of the repository. + :paramtype label: str + :keyword search_paths: Searching path of the repository. + :paramtype search_paths: list[str] + :keyword username: Username of git repository basic auth. + :paramtype username: str + :keyword password: Password of git repository basic auth. + :paramtype password: str + :keyword host_key: Public sshKey of git repository. + :paramtype host_key: str + :keyword host_key_algorithm: SshKey algorithm of git repository. + :paramtype host_key_algorithm: str + :keyword private_key: Private sshKey algorithm of git repository. + :paramtype private_key: str + :keyword strict_host_key_checking: Strict host key checking or not. + :paramtype strict_host_key_checking: bool + """ + super().__init__(**kwargs) + self.repositories = repositories + self.uri = uri + self.label = label + self.search_paths = search_paths + self.username = username + self.password = password + self.host_key = host_key + self.host_key_algorithm = host_key_algorithm + self.private_key = private_key + self.strict_host_key_checking = strict_host_key_checking + + +class ConfigServerProperties(_serialization.Model): + """Config server git properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the config server. Known values are: "NotAvailable", + "Deleted", "Failed", "Succeeded", and "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerState + :ivar error: Error when apply config server settings. + :vartype error: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Error + :ivar config_server: Settings of config server. + :vartype config_server: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerSettings + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "config_server": {"key": "configServer", "type": "ConfigServerSettings"}, + } + + def __init__( + self, + *, + error: Optional["_models.Error"] = None, + config_server: Optional["_models.ConfigServerSettings"] = None, + **kwargs + ): + """ + :keyword error: Error when apply config server settings. + :paramtype error: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Error + :keyword config_server: Settings of config server. + :paramtype config_server: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerSettings + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.error = error + self.config_server = config_server + + +class ConfigServerResource(ProxyResource): + """Config Server resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Properties of the Config Server resource. + :vartype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerProperties + """ + + _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": "ConfigServerProperties"}, + } + + def __init__(self, *, properties: Optional["_models.ConfigServerProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the Config Server resource. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ConfigServerSettings(_serialization.Model): + """The settings of config server. + + :ivar git_property: Property of git environment. + :vartype git_property: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerGitProperty + """ + + _attribute_map = { + "git_property": {"key": "gitProperty", "type": "ConfigServerGitProperty"}, + } + + def __init__(self, *, git_property: Optional["_models.ConfigServerGitProperty"] = None, **kwargs): + """ + :keyword git_property: Property of git environment. + :paramtype git_property: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerGitProperty + """ + super().__init__(**kwargs) + self.git_property = git_property + + +class ConfigServerSettingsErrorRecord(_serialization.Model): + """Error record of the config server settings. + + :ivar name: The name of the config server settings error record. + :vartype name: str + :ivar uri: The uri of the config server settings error record. + :vartype uri: str + :ivar messages: The detail error messages of the record. + :vartype messages: list[str] + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, + } + + def __init__( + self, *, name: Optional[str] = None, uri: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs + ): + """ + :keyword name: The name of the config server settings error record. + :paramtype name: str + :keyword uri: The uri of the config server settings error record. + :paramtype uri: str + :keyword messages: The detail error messages of the record. + :paramtype messages: list[str] + """ + super().__init__(**kwargs) + self.name = name + self.uri = uri + self.messages = messages + + +class ConfigServerSettingsValidateResult(_serialization.Model): + """Validation result for config server settings. + + :ivar is_valid: Indicate if the config server settings are valid. + :vartype is_valid: bool + :ivar details: The detail validation results. + :vartype details: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerSettingsErrorRecord] + """ + + _attribute_map = { + "is_valid": {"key": "isValid", "type": "bool"}, + "details": {"key": "details", "type": "[ConfigServerSettingsErrorRecord]"}, + } + + def __init__( + self, + *, + is_valid: Optional[bool] = None, + details: Optional[List["_models.ConfigServerSettingsErrorRecord"]] = None, + **kwargs + ): + """ + :keyword is_valid: Indicate if the config server settings are valid. + :paramtype is_valid: bool + :keyword details: The detail validation results. + :paramtype details: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerSettingsErrorRecord] + """ + super().__init__(**kwargs) + self.is_valid = is_valid + self.details = details + + +class ConfigurationServiceGitProperty(_serialization.Model): + """Property of git environment. + + :ivar repositories: Repositories of Application Configuration Service git property. + :vartype repositories: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceGitRepository] + """ + + _attribute_map = { + "repositories": {"key": "repositories", "type": "[ConfigurationServiceGitRepository]"}, + } + + def __init__(self, *, repositories: Optional[List["_models.ConfigurationServiceGitRepository"]] = None, **kwargs): + """ + :keyword repositories: Repositories of Application Configuration Service git property. + :paramtype repositories: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceGitRepository] + """ + super().__init__(**kwargs) + self.repositories = repositories + + +class ConfigurationServiceGitPropertyValidateResult(_serialization.Model): + """Validation result for configuration service settings. + + :ivar is_valid: Indicate if the configuration service settings are valid. + :vartype is_valid: bool + :ivar git_repos_validation_result: The detail validation results. + :vartype git_repos_validation_result: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ValidationMessages] + """ + + _attribute_map = { + "is_valid": {"key": "isValid", "type": "bool"}, + "git_repos_validation_result": {"key": "gitReposValidationResult", "type": "[ValidationMessages]"}, + } + + def __init__( + self, + *, + is_valid: Optional[bool] = None, + git_repos_validation_result: Optional[List["_models.ValidationMessages"]] = None, + **kwargs + ): + """ + :keyword is_valid: Indicate if the configuration service settings are valid. + :paramtype is_valid: bool + :keyword git_repos_validation_result: The detail validation results. + :paramtype git_repos_validation_result: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ValidationMessages] + """ + super().__init__(**kwargs) + self.is_valid = is_valid + self.git_repos_validation_result = git_repos_validation_result + + +class ConfigurationServiceGitRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Git repository property payload for Application Configuration Service. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name of the repository. Required. + :vartype name: str + :ivar patterns: Collection of patterns of the repository. Required. + :vartype patterns: list[str] + :ivar uri: URI of the repository. Required. + :vartype uri: str + :ivar label: Label of the repository. Required. + :vartype label: str + :ivar search_paths: Searching path of the repository. + :vartype search_paths: list[str] + :ivar username: Username of git repository basic auth. + :vartype username: str + :ivar password: Password of git repository basic auth. + :vartype password: str + :ivar host_key: Public sshKey of git repository. + :vartype host_key: str + :ivar host_key_algorithm: SshKey algorithm of git repository. + :vartype host_key_algorithm: str + :ivar private_key: Private sshKey algorithm of git repository. + :vartype private_key: str + :ivar strict_host_key_checking: Strict host key checking or not. + :vartype strict_host_key_checking: bool + """ + + _validation = { + "name": {"required": True}, + "patterns": {"required": True}, + "uri": {"required": True}, + "label": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "patterns": {"key": "patterns", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, + } + + def __init__( + self, + *, + name: str, + patterns: List[str], + uri: str, + label: str, + search_paths: Optional[List[str]] = None, + username: Optional[str] = None, + password: Optional[str] = None, + host_key: Optional[str] = None, + host_key_algorithm: Optional[str] = None, + private_key: Optional[str] = None, + strict_host_key_checking: Optional[bool] = None, + **kwargs + ): + """ + :keyword name: Name of the repository. Required. + :paramtype name: str + :keyword patterns: Collection of patterns of the repository. Required. + :paramtype patterns: list[str] + :keyword uri: URI of the repository. Required. + :paramtype uri: str + :keyword label: Label of the repository. Required. + :paramtype label: str + :keyword search_paths: Searching path of the repository. + :paramtype search_paths: list[str] + :keyword username: Username of git repository basic auth. + :paramtype username: str + :keyword password: Password of git repository basic auth. + :paramtype password: str + :keyword host_key: Public sshKey of git repository. + :paramtype host_key: str + :keyword host_key_algorithm: SshKey algorithm of git repository. + :paramtype host_key_algorithm: str + :keyword private_key: Private sshKey algorithm of git repository. + :paramtype private_key: str + :keyword strict_host_key_checking: Strict host key checking or not. + :paramtype strict_host_key_checking: bool + """ + super().__init__(**kwargs) + self.name = name + self.patterns = patterns + self.uri = uri + self.label = label + self.search_paths = search_paths + self.username = username + self.password = password + self.host_key = host_key + self.host_key_algorithm = host_key_algorithm + self.private_key = private_key + self.strict_host_key_checking = strict_host_key_checking + + +class ConfigurationServiceInstance(_serialization.Model): + """Collection of instances belong to the Application Configuration Service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Application Configuration Service instance. + :vartype name: str + :ivar status: Status of the Application Configuration Service instance. + :vartype status: str + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + + +class ConfigurationServiceProperties(_serialization.Model): + """Application Configuration Service properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the Application Configuration Service. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceProvisioningState + :ivar resource_requests: The requested resource quantity for required CPU and Memory. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResourceRequests + :ivar instances: Collection of instances belong to Application Configuration Service. + :vartype instances: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceInstance] + :ivar settings: The settings of Application Configuration Service. + :vartype settings: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceSettings + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "ConfigurationServiceResourceRequests"}, + "instances": {"key": "instances", "type": "[ConfigurationServiceInstance]"}, + "settings": {"key": "settings", "type": "ConfigurationServiceSettings"}, + } + + def __init__(self, *, settings: Optional["_models.ConfigurationServiceSettings"] = None, **kwargs): + """ + :keyword settings: The settings of Application Configuration Service. + :paramtype settings: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceSettings + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.resource_requests = None + self.instances = None + self.settings = settings + + +class ConfigurationServiceResource(ProxyResource): + """Application Configuration Service resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Application Configuration Service properties payload. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceProperties + """ + + _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": "ConfigurationServiceProperties"}, + } + + def __init__(self, *, properties: Optional["_models.ConfigurationServiceProperties"] = None, **kwargs): + """ + :keyword properties: Application Configuration Service properties payload. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ConfigurationServiceResourceCollection(_serialization.Model): + """Object that includes an array of configuration service resources and a possible link for next set. + + :ivar value: Collection of configuration service resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ConfigurationServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ConfigurationServiceResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of configuration service resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ConfigurationServiceResourceRequests(_serialization.Model): + """Resource request payload of Application Configuration Service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: Cpu allocated to each Application Configuration Service instance. + :vartype cpu: str + :ivar memory: Memory allocated to each Application Configuration Service instance. + :vartype memory: str + :ivar instance_count: Instance count of the Application Configuration Service. + :vartype instance_count: int + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, + } + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.cpu = None + self.memory = None + self.instance_count = None + + +class ConfigurationServiceSettings(_serialization.Model): + """The settings of Application Configuration Service. + + :ivar git_property: Property of git environment. + :vartype git_property: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceGitProperty + """ + + _attribute_map = { + "git_property": {"key": "gitProperty", "type": "ConfigurationServiceGitProperty"}, + } + + def __init__(self, *, git_property: Optional["_models.ConfigurationServiceGitProperty"] = None, **kwargs): + """ + :keyword git_property: Property of git environment. + :paramtype git_property: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceGitProperty + """ + super().__init__(**kwargs) + self.git_property = git_property + + +class ConfigurationServiceSettingsValidateResult(_serialization.Model): + """Validation result for configuration service settings. + + :ivar git_property_validation_result: Validation result for configuration service settings. + :vartype git_property_validation_result: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceGitPropertyValidateResult + """ + + _attribute_map = { + "git_property_validation_result": { + "key": "gitPropertyValidationResult", + "type": "ConfigurationServiceGitPropertyValidateResult", + }, + } + + def __init__( + self, + *, + git_property_validation_result: Optional["_models.ConfigurationServiceGitPropertyValidateResult"] = None, + **kwargs + ): + """ + :keyword git_property_validation_result: Validation result for configuration service settings. + :paramtype git_property_validation_result: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceGitPropertyValidateResult + """ + super().__init__(**kwargs) + self.git_property_validation_result = git_property_validation_result + + +class ContainerProbeSettings(_serialization.Model): + """Container liveness and readiness probe settings. + + :ivar disable_probe: Indicates whether disable the liveness and readiness probe. + :vartype disable_probe: bool + """ + + _attribute_map = { + "disable_probe": {"key": "disableProbe", "type": "bool"}, + } + + def __init__(self, *, disable_probe: Optional[bool] = None, **kwargs): + """ + :keyword disable_probe: Indicates whether disable the liveness and readiness probe. + :paramtype disable_probe: bool + """ + super().__init__(**kwargs) + self.disable_probe = disable_probe + + +class ContentCertificateProperties(CertificateProperties): + """Properties of certificate imported from key vault. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the certificate source. Required. + :vartype type: str + :ivar thumbprint: The thumbprint of certificate. + :vartype thumbprint: str + :ivar issuer: The issuer of certificate. + :vartype issuer: str + :ivar issued_date: The issue date of certificate. + :vartype issued_date: str + :ivar expiration_date: The expiration date of certificate. + :vartype expiration_date: str + :ivar activate_date: The activate date of certificate. + :vartype activate_date: str + :ivar subject_name: The subject name of certificate. + :vartype subject_name: str + :ivar dns_names: The domain list of certificate. + :vartype dns_names: list[str] + :ivar provisioning_state: Provisioning state of the Certificate. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResourceProvisioningState + :ivar content: The content of uploaded certificate. + :vartype content: str + """ + + _validation = { + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "content": {"key": "content", "type": "str"}, + } + + def __init__(self, *, content: Optional[str] = None, **kwargs): + """ + :keyword content: The content of uploaded certificate. + :paramtype content: str + """ + super().__init__(**kwargs) + self.type = "ContentCertificate" # type: str + self.content = content + + +class CustomContainer(_serialization.Model): + """Custom container payload. + + :ivar server: The name of the registry that contains the container image. + :vartype server: str + :ivar container_image: Container image of the custom container. This should be in the form of + :code:``::code:`` without the server name of the registry. + :vartype container_image: str + :ivar command: Entrypoint array. Not executed within a shell. The docker image's ENTRYPOINT is + used if this is not provided. + :vartype command: list[str] + :ivar args: Arguments to the entrypoint. The docker image's CMD is used if this is not + provided. + :vartype args: list[str] + :ivar image_registry_credential: Credential of the image registry. + :vartype image_registry_credential: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ImageRegistryCredential + :ivar language_framework: Language framework of the container image uploaded. + :vartype language_framework: str + """ + + _attribute_map = { + "server": {"key": "server", "type": "str"}, + "container_image": {"key": "containerImage", "type": "str"}, + "command": {"key": "command", "type": "[str]"}, + "args": {"key": "args", "type": "[str]"}, + "image_registry_credential": {"key": "imageRegistryCredential", "type": "ImageRegistryCredential"}, + "language_framework": {"key": "languageFramework", "type": "str"}, + } + + def __init__( + self, + *, + server: Optional[str] = None, + container_image: Optional[str] = None, + command: Optional[List[str]] = None, + args: Optional[List[str]] = None, + image_registry_credential: Optional["_models.ImageRegistryCredential"] = None, + language_framework: Optional[str] = None, + **kwargs + ): + """ + :keyword server: The name of the registry that contains the container image. + :paramtype server: str + :keyword container_image: Container image of the custom container. This should be in the form + of :code:``::code:`` without the server name of the registry. + :paramtype container_image: str + :keyword command: Entrypoint array. Not executed within a shell. The docker image's ENTRYPOINT + is used if this is not provided. + :paramtype command: list[str] + :keyword args: Arguments to the entrypoint. The docker image's CMD is used if this is not + provided. + :paramtype args: list[str] + :keyword image_registry_credential: Credential of the image registry. + :paramtype image_registry_credential: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ImageRegistryCredential + :keyword language_framework: Language framework of the container image uploaded. + :paramtype language_framework: str + """ + super().__init__(**kwargs) + self.server = server + self.container_image = container_image + self.command = command + self.args = args + self.image_registry_credential = image_registry_credential + self.language_framework = language_framework + + +class CustomContainerUserSourceInfo(UserSourceInfo): + """Custom container user source info. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the source uploaded. Required. + :vartype type: str + :ivar version: Version of the source. + :vartype version: str + :ivar custom_container: Custom container payload. + :vartype custom_container: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomContainer + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "custom_container": {"key": "customContainer", "type": "CustomContainer"}, + } + + def __init__( + self, *, version: Optional[str] = None, custom_container: Optional["_models.CustomContainer"] = None, **kwargs + ): + """ + :keyword version: Version of the source. + :paramtype version: str + :keyword custom_container: Custom container payload. + :paramtype custom_container: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomContainer + """ + super().__init__(version=version, **kwargs) + self.type = "Container" # type: str + self.custom_container = custom_container + + +class CustomDomainProperties(_serialization.Model): + """Custom domain of app resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar thumbprint: The thumbprint of bound certificate. + :vartype thumbprint: str + :ivar app_name: The app name of domain. + :vartype app_name: str + :ivar cert_name: The bound certificate name of domain. + :vartype cert_name: str + :ivar provisioning_state: Provisioning state of the Domain. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResourceProvisioningState + """ + + _validation = { + "app_name": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "thumbprint": {"key": "thumbprint", "type": "str"}, + "app_name": {"key": "appName", "type": "str"}, + "cert_name": {"key": "certName", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + } + + def __init__(self, *, thumbprint: Optional[str] = None, cert_name: Optional[str] = None, **kwargs): + """ + :keyword thumbprint: The thumbprint of bound certificate. + :paramtype thumbprint: str + :keyword cert_name: The bound certificate name of domain. + :paramtype cert_name: str + """ + super().__init__(**kwargs) + self.thumbprint = thumbprint + self.app_name = None + self.cert_name = cert_name + self.provisioning_state = None + + +class CustomDomainResource(ProxyResource): + """Custom domain resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Properties of the custom domain resource. + :vartype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainProperties + """ + + _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": "CustomDomainProperties"}, + } + + def __init__(self, *, properties: Optional["_models.CustomDomainProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the custom domain resource. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class CustomDomainResourceCollection(_serialization.Model): + """Collection compose of a custom domain resources list and a possible link for next page. + + :ivar value: The custom domain resources list. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :ivar next_link: The link to next page of custom domain list. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[CustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.CustomDomainResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The custom domain resources list. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :keyword next_link: The link to next page of custom domain list. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CustomDomainValidatePayload(_serialization.Model): + """Custom domain validate payload. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name to be validated. Required. + :vartype name: str + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: str, **kwargs): + """ + :keyword name: Name to be validated. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class CustomDomainValidateResult(_serialization.Model): + """Validation result for custom domain. + + :ivar is_valid: Indicates if domain name is valid. + :vartype is_valid: bool + :ivar message: Message of why domain name is invalid. + :vartype message: str + """ + + _attribute_map = { + "is_valid": {"key": "isValid", "type": "bool"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, is_valid: Optional[bool] = None, message: Optional[str] = None, **kwargs): + """ + :keyword is_valid: Indicates if domain name is valid. + :paramtype is_valid: bool + :keyword message: Message of why domain name is invalid. + :paramtype message: str + """ + super().__init__(**kwargs) + self.is_valid = is_valid + self.message = message + + +class CustomizedAcceleratorProperties(_serialization.Model): + """Customized accelerator properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar provisioning_state: State of the customized accelerator. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorProvisioningState + :ivar display_name: + :vartype display_name: str + :ivar description: + :vartype description: str + :ivar icon_url: + :vartype icon_url: str + :ivar accelerator_tags: + :vartype accelerator_tags: list[str] + :ivar git_repository: Required. + :vartype git_repository: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.AcceleratorGitRepository + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "git_repository": {"required": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "icon_url": {"key": "iconUrl", "type": "str"}, + "accelerator_tags": {"key": "acceleratorTags", "type": "[str]"}, + "git_repository": {"key": "gitRepository", "type": "AcceleratorGitRepository"}, + } + + def __init__( + self, + *, + git_repository: "_models.AcceleratorGitRepository", + display_name: Optional[str] = None, + description: Optional[str] = None, + icon_url: Optional[str] = None, + accelerator_tags: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword display_name: + :paramtype display_name: str + :keyword description: + :paramtype description: str + :keyword icon_url: + :paramtype icon_url: str + :keyword accelerator_tags: + :paramtype accelerator_tags: list[str] + :keyword git_repository: Required. + :paramtype git_repository: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.AcceleratorGitRepository + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.display_name = display_name + self.description = description + self.icon_url = icon_url + self.accelerator_tags = accelerator_tags + self.git_repository = git_repository + + +class CustomizedAcceleratorResource(ProxyResource): + """Customized accelerator resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Customized accelerator properties payload. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorProperties + :ivar sku: Sku of the customized accelerator resource. + :vartype sku: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Sku + """ + + _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": "CustomizedAcceleratorProperties"}, + "sku": {"key": "sku", "type": "Sku"}, + } + + def __init__( + self, + *, + properties: Optional["_models.CustomizedAcceleratorProperties"] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword properties: Customized accelerator properties payload. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorProperties + :keyword sku: Sku of the customized accelerator resource. + :paramtype sku: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Sku + """ + super().__init__(**kwargs) + self.properties = properties + self.sku = sku + + +class CustomizedAcceleratorResourceCollection(_serialization.Model): + """CustomizedAcceleratorResourceCollection. + + :ivar value: + :vartype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource] + :ivar next_link: + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[CustomizedAcceleratorResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.CustomizedAcceleratorResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: + :paramtype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource] + :keyword next_link: + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CustomizedAcceleratorValidateResult(_serialization.Model): + """Validation result for customized accelerator properties. + + :ivar state: State of the customized accelerator validation result. Known values are: "Valid" + and "Invalid". + :vartype state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorValidateResultState + :ivar error_message: The detail validation results. + :vartype error_message: str + """ + + _attribute_map = { + "state": {"key": "state", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + } + + def __init__( + self, + *, + state: Union[str, "_models.CustomizedAcceleratorValidateResultState"] = "Valid", + error_message: Optional[str] = None, + **kwargs + ): + """ + :keyword state: State of the customized accelerator validation result. Known values are: + "Valid" and "Invalid". + :paramtype state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorValidateResultState + :keyword error_message: The detail validation results. + :paramtype error_message: str + """ + super().__init__(**kwargs) + self.state = state + self.error_message = error_message + + +class CustomPersistentDiskResource(_serialization.Model): + """Custom persistent disk resource payload. + + All required parameters must be populated in order to send to Azure. + + :ivar custom_persistent_disk_properties: Properties of the custom persistent disk resource + payload. + :vartype custom_persistent_disk_properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomPersistentDiskProperties + :ivar storage_id: The resource id of Azure Spring Apps Storage resource. Required. + :vartype storage_id: str + """ + + _validation = { + "storage_id": {"required": True}, + } + + _attribute_map = { + "custom_persistent_disk_properties": { + "key": "customPersistentDiskProperties", + "type": "CustomPersistentDiskProperties", + }, + "storage_id": {"key": "storageId", "type": "str"}, + } + + def __init__( + self, + *, + storage_id: str, + custom_persistent_disk_properties: Optional["_models.CustomPersistentDiskProperties"] = None, + **kwargs + ): + """ + :keyword custom_persistent_disk_properties: Properties of the custom persistent disk resource + payload. + :paramtype custom_persistent_disk_properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomPersistentDiskProperties + :keyword storage_id: The resource id of Azure Spring Apps Storage resource. Required. + :paramtype storage_id: str + """ + super().__init__(**kwargs) + self.custom_persistent_disk_properties = custom_persistent_disk_properties + self.storage_id = storage_id + + +class DeploymentInstance(_serialization.Model): + """Deployment instance payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the deployment instance. + :vartype name: str + :ivar status: Status of the deployment instance. + :vartype status: str + :ivar reason: Failed reason of the deployment instance. + :vartype reason: str + :ivar discovery_status: Discovery status of the deployment instance. + :vartype discovery_status: str + :ivar start_time: Start time of the deployment instance. + :vartype start_time: str + :ivar zone: Availability zone information of the deployment instance. + :vartype zone: str + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + "reason": {"readonly": True}, + "discovery_status": {"readonly": True}, + "start_time": {"readonly": True}, + "zone": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "discovery_status": {"key": "discoveryStatus", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, + "zone": {"key": "zone", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + self.reason = None + self.discovery_status = None + self.start_time = None + self.zone = None + + +class DeploymentList(_serialization.Model): + """A list of deployments resource ids. + + :ivar deployments: A list of deployment resource ids. + :vartype deployments: list[str] + """ + + _attribute_map = { + "deployments": {"key": "deployments", "type": "[str]"}, + } + + def __init__(self, *, deployments: Optional[List[str]] = None, **kwargs): + """ + :keyword deployments: A list of deployment resource ids. + :paramtype deployments: list[str] + """ + super().__init__(**kwargs) + self.deployments = deployments + + +class DeploymentResource(ProxyResource): + """Deployment resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Properties of the Deployment resource. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResourceProperties + :ivar sku: Sku of the Deployment resource. + :vartype sku: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Sku + """ + + _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": "DeploymentResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, + } + + def __init__( + self, + *, + properties: Optional["_models.DeploymentResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword properties: Properties of the Deployment resource. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResourceProperties + :keyword sku: Sku of the Deployment resource. + :paramtype sku: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Sku + """ + super().__init__(**kwargs) + self.properties = properties + self.sku = sku + + +class DeploymentResourceCollection(_serialization.Model): + """Object that includes an array of App resources and a possible link for next set. + + :ivar value: Collection of Deployment resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[DeploymentResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.DeploymentResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of Deployment resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class DeploymentResourceProperties(_serialization.Model): + """Deployment resource properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar source: Uploaded source information of the deployment. + :vartype source: ~azure.mgmt.appplatform.v2022_11_01_preview.models.UserSourceInfo + :ivar deployment_settings: Deployment settings of the Deployment. + :vartype deployment_settings: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentSettings + :ivar provisioning_state: Provisioning state of the Deployment. Known values are: "Creating", + "Updating", "Succeeded", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResourceProvisioningState + :ivar status: Status of the Deployment. Known values are: "Stopped" and "Running". + :vartype status: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResourceStatus + :ivar active: Indicates whether the Deployment is active. + :vartype active: bool + :ivar instances: Collection of instances belong to the Deployment. + :vartype instances: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentInstance] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "instances": {"readonly": True}, + } + + _attribute_map = { + "source": {"key": "source", "type": "UserSourceInfo"}, + "deployment_settings": {"key": "deploymentSettings", "type": "DeploymentSettings"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "active": {"key": "active", "type": "bool"}, + "instances": {"key": "instances", "type": "[DeploymentInstance]"}, + } + + def __init__( + self, + *, + source: Optional["_models.UserSourceInfo"] = None, + deployment_settings: Optional["_models.DeploymentSettings"] = None, + active: Optional[bool] = None, + **kwargs + ): + """ + :keyword source: Uploaded source information of the deployment. + :paramtype source: ~azure.mgmt.appplatform.v2022_11_01_preview.models.UserSourceInfo + :keyword deployment_settings: Deployment settings of the Deployment. + :paramtype deployment_settings: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentSettings + :keyword active: Indicates whether the Deployment is active. + :paramtype active: bool + """ + super().__init__(**kwargs) + self.source = source + self.deployment_settings = deployment_settings + self.provisioning_state = None + self.status = None + self.active = active + self.instances = None + + +class DeploymentSettings(_serialization.Model): + """Deployment settings payload. + + :ivar resource_requests: The requested resource quantity for required CPU and Memory. It is + recommended that using this field to represent the required CPU and Memory, the old field cpu + and memoryInGB will be deprecated later. + :vartype resource_requests: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceRequests + :ivar environment_variables: Collection of environment variables. + :vartype environment_variables: dict[str, str] + :ivar addon_configs: Collection of addons. + :vartype addon_configs: dict[str, dict[str, JSON]] + :ivar liveness_probe: Periodic probe of App Instance liveness. App Instance will be restarted + if the probe fails. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :vartype liveness_probe: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Probe + :ivar readiness_probe: Periodic probe of App Instance service readiness. App Instance will be + removed from service endpoints if the probe fails. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :vartype readiness_probe: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Probe + :ivar startup_probe: StartupProbe indicates that the App Instance has successfully initialized. + If specified, no other probes are executed until this completes successfully. If this probe + fails, the Pod will be restarted, just as if the livenessProbe failed. This can be used to + provide different probe parameters at the beginning of a App Instance's lifecycle, when it + might take a long time to load data or warm a cache, than during steady-state operation. This + cannot be updated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :vartype startup_probe: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Probe + :ivar termination_grace_period_seconds: Optional duration in seconds the App Instance needs to + terminate gracefully. May be decreased in delete request. Value must be non-negative integer. + The value zero indicates stop immediately via the kill signal (no opportunity to shut down). If + this value is nil, the default grace period will be used instead. The grace period is the + duration in seconds after the processes running in the App Instance are sent a termination + signal and the time when the processes are forcibly halted with a kill signal. Set this value + longer than the expected cleanup time for your process. Defaults to 90 seconds. + :vartype termination_grace_period_seconds: int + :ivar container_probe_settings: Container liveness and readiness probe settings. + :vartype container_probe_settings: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ContainerProbeSettings + """ + + _attribute_map = { + "resource_requests": {"key": "resourceRequests", "type": "ResourceRequests"}, + "environment_variables": {"key": "environmentVariables", "type": "{str}"}, + "addon_configs": {"key": "addonConfigs", "type": "{{object}}"}, + "liveness_probe": {"key": "livenessProbe", "type": "Probe"}, + "readiness_probe": {"key": "readinessProbe", "type": "Probe"}, + "startup_probe": {"key": "startupProbe", "type": "Probe"}, + "termination_grace_period_seconds": {"key": "terminationGracePeriodSeconds", "type": "int"}, + "container_probe_settings": {"key": "containerProbeSettings", "type": "ContainerProbeSettings"}, + } + + def __init__( + self, + *, + resource_requests: Optional["_models.ResourceRequests"] = None, + environment_variables: Optional[Dict[str, str]] = None, + addon_configs: Optional[Dict[str, Dict[str, JSON]]] = None, + liveness_probe: Optional["_models.Probe"] = None, + readiness_probe: Optional["_models.Probe"] = None, + startup_probe: Optional["_models.Probe"] = None, + termination_grace_period_seconds: int = 90, + container_probe_settings: Optional["_models.ContainerProbeSettings"] = None, + **kwargs + ): + """ + :keyword resource_requests: The requested resource quantity for required CPU and Memory. It is + recommended that using this field to represent the required CPU and Memory, the old field cpu + and memoryInGB will be deprecated later. + :paramtype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceRequests + :keyword environment_variables: Collection of environment variables. + :paramtype environment_variables: dict[str, str] + :keyword addon_configs: Collection of addons. + :paramtype addon_configs: dict[str, dict[str, JSON]] + :keyword liveness_probe: Periodic probe of App Instance liveness. App Instance will be + restarted if the probe fails. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :paramtype liveness_probe: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Probe + :keyword readiness_probe: Periodic probe of App Instance service readiness. App Instance will + be removed from service endpoints if the probe fails. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :paramtype readiness_probe: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Probe + :keyword startup_probe: StartupProbe indicates that the App Instance has successfully + initialized. If specified, no other probes are executed until this completes successfully. If + this probe fails, the Pod will be restarted, just as if the livenessProbe failed. This can be + used to provide different probe parameters at the beginning of a App Instance's lifecycle, when + it might take a long time to load data or warm a cache, than during steady-state operation. + This cannot be updated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :paramtype startup_probe: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Probe + :keyword termination_grace_period_seconds: Optional duration in seconds the App Instance needs + to terminate gracefully. May be decreased in delete request. Value must be non-negative + integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut + down). If this value is nil, the default grace period will be used instead. The grace period is + the duration in seconds after the processes running in the App Instance are sent a termination + signal and the time when the processes are forcibly halted with a kill signal. Set this value + longer than the expected cleanup time for your process. Defaults to 90 seconds. + :paramtype termination_grace_period_seconds: int + :keyword container_probe_settings: Container liveness and readiness probe settings. + :paramtype container_probe_settings: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ContainerProbeSettings + """ + super().__init__(**kwargs) + self.resource_requests = resource_requests + self.environment_variables = environment_variables + self.addon_configs = addon_configs + self.liveness_probe = liveness_probe + self.readiness_probe = readiness_probe + self.startup_probe = startup_probe + self.termination_grace_period_seconds = termination_grace_period_seconds + self.container_probe_settings = container_probe_settings + + +class DevToolPortalFeatureDetail(_serialization.Model): + """Detail settings for Dev Tool Portal feature. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar state: State of the plugin. Known values are: "Enabled" and "Disabled". + :vartype state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalFeatureState + :ivar route: Route path to visit the plugin. + :vartype route: str + """ + + _validation = { + "route": {"readonly": True}, + } + + _attribute_map = { + "state": {"key": "state", "type": "str"}, + "route": {"key": "route", "type": "str"}, + } + + def __init__(self, *, state: Union[str, "_models.DevToolPortalFeatureState"] = "Enabled", **kwargs): + """ + :keyword state: State of the plugin. Known values are: "Enabled" and "Disabled". + :paramtype state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalFeatureState + """ + super().__init__(**kwargs) + self.state = state + self.route = None + + +class DevToolPortalFeatureSettings(_serialization.Model): + """Settings for Dev Tool Portal. + + :ivar application_accelerator: Detail of Accelerator plugin. + :vartype application_accelerator: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalFeatureDetail + :ivar application_live_view: Detail of App Live View plugin. + :vartype application_live_view: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalFeatureDetail + """ + + _attribute_map = { + "application_accelerator": {"key": "applicationAccelerator", "type": "DevToolPortalFeatureDetail"}, + "application_live_view": {"key": "applicationLiveView", "type": "DevToolPortalFeatureDetail"}, + } + + def __init__( + self, + *, + application_accelerator: Optional["_models.DevToolPortalFeatureDetail"] = None, + application_live_view: Optional["_models.DevToolPortalFeatureDetail"] = None, + **kwargs + ): + """ + :keyword application_accelerator: Detail of Accelerator plugin. + :paramtype application_accelerator: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalFeatureDetail + :keyword application_live_view: Detail of App Live View plugin. + :paramtype application_live_view: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalFeatureDetail + """ + super().__init__(**kwargs) + self.application_accelerator = application_accelerator + self.application_live_view = application_live_view + + +class DevToolPortalInstance(_serialization.Model): + """Collection of instances belong to the Dev Tool Portal. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Dev Tool Portal instance. + :vartype name: str + :ivar status: Status of the Dev Tool Portal instance. It can be Pending, Running, Succeeded, + Failed, Unknown. + :vartype status: str + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + + +class DevToolPortalProperties(_serialization.Model): + """Dev Tool Portal properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the Dev Tool Portal. Known values are: "Creating", + "Updating", "Succeeded", "Failed", "Deleting", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalProvisioningState + :ivar resource_requests: The requested resource quantity for required CPU and Memory. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResourceRequests + :ivar instances: Collection of instances belong to Dev Tool Portal. + :vartype instances: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalInstance] + :ivar public: Indicates whether the resource exposes public endpoint. + :vartype public: bool + :ivar url: URL of the resource, exposed when 'public' is true. + :vartype url: str + :ivar sso_properties: Single sign-on related configuration. + :vartype sso_properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalSsoProperties + :ivar features: Settings for Dev Tool Portal. + :vartype features: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalFeatureSettings + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, + "url": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "DevToolPortalResourceRequests"}, + "instances": {"key": "instances", "type": "[DevToolPortalInstance]"}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "sso_properties": {"key": "ssoProperties", "type": "DevToolPortalSsoProperties"}, + "features": {"key": "features", "type": "DevToolPortalFeatureSettings"}, + } + + def __init__( + self, + *, + public: bool = False, + sso_properties: Optional["_models.DevToolPortalSsoProperties"] = None, + features: Optional["_models.DevToolPortalFeatureSettings"] = None, + **kwargs + ): + """ + :keyword public: Indicates whether the resource exposes public endpoint. + :paramtype public: bool + :keyword sso_properties: Single sign-on related configuration. + :paramtype sso_properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalSsoProperties + :keyword features: Settings for Dev Tool Portal. + :paramtype features: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalFeatureSettings + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.resource_requests = None + self.instances = None + self.public = public + self.url = None + self.sso_properties = sso_properties + self.features = features + + +class DevToolPortalResource(ProxyResource): + """Dev Tool Portal resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Dev Tool Portal properties payload. + :vartype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalProperties + """ + + _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": "DevToolPortalProperties"}, + } + + def __init__(self, *, properties: Optional["_models.DevToolPortalProperties"] = None, **kwargs): + """ + :keyword properties: Dev Tool Portal properties payload. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class DevToolPortalResourceCollection(_serialization.Model): + """Object that includes an array of Dev Tool Portal resources and a possible link for next set. + + :ivar value: Collection of Dev Tool Portal resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[DevToolPortalResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.DevToolPortalResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of Dev Tool Portal resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class DevToolPortalResourceRequests(_serialization.Model): + """The resource quantity for required CPU and Memory of Dev Tool Portal. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: Cpu quantity allocated to each Dev Tool Portal instance. 1 core can be represented + by 1 or 1000m. + :vartype cpu: str + :ivar memory: Memory quantity allocated to each Dev Tool Portal instance. 1 GB can be + represented by 1Gi or 1024Mi. + :vartype memory: str + :ivar instance_count: Desired instance count of Dev Tool Portal. + :vartype instance_count: int + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, + } + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.cpu = None + self.memory = None + self.instance_count = None + + +class DevToolPortalSsoProperties(_serialization.Model): + """Single sign-on related configuration. + + :ivar scopes: It defines the specific actions applications can be allowed to do on a user's + behalf. + :vartype scopes: list[str] + :ivar client_id: The public identifier for the application. + :vartype client_id: str + :ivar client_secret: The secret known only to the application and the authorization server. + :vartype client_secret: str + :ivar metadata_url: The URI of a JSON file with generic OIDC provider configuration. + :vartype metadata_url: str + """ + + _attribute_map = { + "scopes": {"key": "scopes", "type": "[str]"}, + "client_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, + "metadata_url": {"key": "metadataUrl", "type": "str"}, + } + + def __init__( + self, + *, + scopes: Optional[List[str]] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + metadata_url: Optional[str] = None, + **kwargs + ): + """ + :keyword scopes: It defines the specific actions applications can be allowed to do on a user's + behalf. + :paramtype scopes: list[str] + :keyword client_id: The public identifier for the application. + :paramtype client_id: str + :keyword client_secret: The secret known only to the application and the authorization server. + :paramtype client_secret: str + :keyword metadata_url: The URI of a JSON file with generic OIDC provider configuration. + :paramtype metadata_url: str + """ + super().__init__(**kwargs) + self.scopes = scopes + self.client_id = client_id + self.client_secret = client_secret + self.metadata_url = metadata_url + + +class DiagnosticParameters(_serialization.Model): + """Diagnostic parameters of diagnostic operations. + + :ivar app_instance: App instance name. + :vartype app_instance: str + :ivar file_path: Your target file path in your own BYOS. + :vartype file_path: str + :ivar duration: Duration of your JFR. 1 min can be represented by 1m or 60s. + :vartype duration: str + """ + + _attribute_map = { + "app_instance": {"key": "appInstance", "type": "str"}, + "file_path": {"key": "filePath", "type": "str"}, + "duration": {"key": "duration", "type": "str"}, + } + + def __init__( + self, + *, + app_instance: Optional[str] = None, + file_path: Optional[str] = None, + duration: Optional[str] = None, + **kwargs + ): + """ + :keyword app_instance: App instance name. + :paramtype app_instance: str + :keyword file_path: Your target file path in your own BYOS. + :paramtype file_path: str + :keyword duration: Duration of your JFR. 1 min can be represented by 1m or 60s. + :paramtype duration: str + """ + super().__init__(**kwargs) + self.app_instance = app_instance + self.file_path = file_path + self.duration = duration + + +class Error(_serialization.Model): + """The error code compose of code and message. + + :ivar code: The code of error. + :vartype code: str + :ivar message: The message of error. + :vartype message: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + """ + :keyword code: The code of error. + :paramtype code: str + :keyword message: The message of error. + :paramtype message: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + + +class ProbeAction(_serialization.Model): + """The action of the probe. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ExecAction, HTTPGetAction, TCPSocketAction + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the action to take to perform the health check. Required. Known values + are: "HTTPGetAction", "TCPSocketAction", and "ExecAction". + :vartype type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.ProbeActionType + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + _subtype_map = { + "type": {"ExecAction": "ExecAction", "HTTPGetAction": "HTTPGetAction", "TCPSocketAction": "TCPSocketAction"} + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type = None # type: Optional[str] + + +class ExecAction(ProbeAction): + """ExecAction describes a "run in container" action. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the action to take to perform the health check. Required. Known values + are: "HTTPGetAction", "TCPSocketAction", and "ExecAction". + :vartype type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.ProbeActionType + :ivar command: Command is the command line to execute inside the container, the working + directory for the command is root ('/') in the container's filesystem. The command is not run + inside a shell, so traditional shell instructions ('|', etc) won't work. To use a shell, you + need to explicitly call out to that shell. Exit status of 0 is treated as live/healthy and + non-zero is unhealthy. + :vartype command: list[str] + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "command": {"key": "command", "type": "[str]"}, + } + + def __init__(self, *, command: Optional[List[str]] = None, **kwargs): + """ + :keyword command: Command is the command line to execute inside the container, the working + directory for the command is root ('/') in the container's filesystem. The command is not run + inside a shell, so traditional shell instructions ('|', etc) won't work. To use a shell, you + need to explicitly call out to that shell. Exit status of 0 is treated as live/healthy and + non-zero is unhealthy. + :paramtype command: list[str] + """ + super().__init__(**kwargs) + self.type = "ExecAction" # type: str + self.command = command + + +class GatewayApiMetadataProperties(_serialization.Model): + """API metadata property for Spring Cloud Gateway. + + :ivar title: Title describing the context of the APIs available on the Gateway instance + (default: ``Spring Cloud Gateway for K8S``\ ). + :vartype title: str + :ivar description: Detailed description of the APIs available on the Gateway instance (default: + ``Generated OpenAPI 3 document that describes the API routes configured.``\ ). + :vartype description: str + :ivar documentation: Location of additional documentation for the APIs available on the Gateway + instance. + :vartype documentation: str + :ivar version: Version of APIs available on this Gateway instance (default: ``unspecified``\ ). + :vartype version: str + :ivar server_url: Base URL that API consumers will use to access APIs on the Gateway instance. + :vartype server_url: str + """ + + _attribute_map = { + "title": {"key": "title", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "documentation": {"key": "documentation", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "server_url": {"key": "serverUrl", "type": "str"}, + } + + def __init__( + self, + *, + title: Optional[str] = None, + description: Optional[str] = None, + documentation: Optional[str] = None, + version: Optional[str] = None, + server_url: Optional[str] = None, + **kwargs + ): + """ + :keyword title: Title describing the context of the APIs available on the Gateway instance + (default: ``Spring Cloud Gateway for K8S``\ ). + :paramtype title: str + :keyword description: Detailed description of the APIs available on the Gateway instance + (default: ``Generated OpenAPI 3 document that describes the API routes configured.``\ ). + :paramtype description: str + :keyword documentation: Location of additional documentation for the APIs available on the + Gateway instance. + :paramtype documentation: str + :keyword version: Version of APIs available on this Gateway instance (default: ``unspecified``\ + ). + :paramtype version: str + :keyword server_url: Base URL that API consumers will use to access APIs on the Gateway + instance. + :paramtype server_url: str + """ + super().__init__(**kwargs) + self.title = title + self.description = description + self.documentation = documentation + self.version = version + self.server_url = server_url + + +class GatewayApiRoute(_serialization.Model): + """API route config of the Spring Cloud Gateway. + + :ivar title: A title, will be applied to methods in the generated OpenAPI documentation. + :vartype title: str + :ivar description: A description, will be applied to methods in the generated OpenAPI + documentation. + :vartype description: str + :ivar uri: Full uri, will override ``appName``. + :vartype uri: str + :ivar sso_enabled: Enable sso validation. + :vartype sso_enabled: bool + :ivar token_relay: Pass currently-authenticated user's identity token to application service, + default is 'false'. + :vartype token_relay: bool + :ivar predicates: A number of conditions to evaluate a route for each request. Each predicate + may be evaluated against request headers and parameter values. All of the predicates associated + with a route must evaluate to true for the route to be matched to the request. + :vartype predicates: list[str] + :ivar filters: To modify the request before sending it to the target endpoint, or the received + response. + :vartype filters: list[str] + :ivar order: Route processing order. + :vartype order: int + :ivar tags: Classification tags, will be applied to methods in the generated OpenAPI + documentation. + :vartype tags: list[str] + """ + + _attribute_map = { + "title": {"key": "title", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "sso_enabled": {"key": "ssoEnabled", "type": "bool"}, + "token_relay": {"key": "tokenRelay", "type": "bool"}, + "predicates": {"key": "predicates", "type": "[str]"}, + "filters": {"key": "filters", "type": "[str]"}, + "order": {"key": "order", "type": "int"}, + "tags": {"key": "tags", "type": "[str]"}, + } + + def __init__( + self, + *, + title: Optional[str] = None, + description: Optional[str] = None, + uri: Optional[str] = None, + sso_enabled: Optional[bool] = None, + token_relay: Optional[bool] = None, + predicates: Optional[List[str]] = None, + filters: Optional[List[str]] = None, + order: Optional[int] = None, + tags: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword title: A title, will be applied to methods in the generated OpenAPI documentation. + :paramtype title: str + :keyword description: A description, will be applied to methods in the generated OpenAPI + documentation. + :paramtype description: str + :keyword uri: Full uri, will override ``appName``. + :paramtype uri: str + :keyword sso_enabled: Enable sso validation. + :paramtype sso_enabled: bool + :keyword token_relay: Pass currently-authenticated user's identity token to application + service, default is 'false'. + :paramtype token_relay: bool + :keyword predicates: A number of conditions to evaluate a route for each request. Each + predicate may be evaluated against request headers and parameter values. All of the predicates + associated with a route must evaluate to true for the route to be matched to the request. + :paramtype predicates: list[str] + :keyword filters: To modify the request before sending it to the target endpoint, or the + received response. + :paramtype filters: list[str] + :keyword order: Route processing order. + :paramtype order: int + :keyword tags: Classification tags, will be applied to methods in the generated OpenAPI + documentation. + :paramtype tags: list[str] + """ + super().__init__(**kwargs) + self.title = title + self.description = description + self.uri = uri + self.sso_enabled = sso_enabled + self.token_relay = token_relay + self.predicates = predicates + self.filters = filters + self.order = order + self.tags = tags + + +class GatewayCorsProperties(_serialization.Model): + """Cross-Origin Resource Sharing property. + + :ivar allowed_origins: Allowed origins to make cross-site requests. The special value ``*`` + allows all domains. + :vartype allowed_origins: list[str] + :ivar allowed_methods: Allowed HTTP methods on cross-site requests. The special value ``*`` + allows all methods. If not set, ``GET`` and ``HEAD`` are allowed by default. + :vartype allowed_methods: list[str] + :ivar allowed_headers: Allowed headers in cross-site requests. The special value ``*`` allows + actual requests to send any header. + :vartype allowed_headers: list[str] + :ivar max_age: How long, in seconds, the response from a pre-flight request can be cached by + clients. + :vartype max_age: int + :ivar allow_credentials: Whether user credentials are supported on cross-site requests. Valid + values: ``true``\ , ``false``. + :vartype allow_credentials: bool + :ivar exposed_headers: HTTP response headers to expose for cross-site requests. + :vartype exposed_headers: list[str] + """ + + _attribute_map = { + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, + "max_age": {"key": "maxAge", "type": "int"}, + "allow_credentials": {"key": "allowCredentials", "type": "bool"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + } + + def __init__( + self, + *, + allowed_origins: Optional[List[str]] = None, + allowed_methods: Optional[List[str]] = None, + allowed_headers: Optional[List[str]] = None, + max_age: Optional[int] = None, + allow_credentials: Optional[bool] = None, + exposed_headers: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword allowed_origins: Allowed origins to make cross-site requests. The special value ``*`` + allows all domains. + :paramtype allowed_origins: list[str] + :keyword allowed_methods: Allowed HTTP methods on cross-site requests. The special value ``*`` + allows all methods. If not set, ``GET`` and ``HEAD`` are allowed by default. + :paramtype allowed_methods: list[str] + :keyword allowed_headers: Allowed headers in cross-site requests. The special value ``*`` + allows actual requests to send any header. + :paramtype allowed_headers: list[str] + :keyword max_age: How long, in seconds, the response from a pre-flight request can be cached by + clients. + :paramtype max_age: int + :keyword allow_credentials: Whether user credentials are supported on cross-site requests. + Valid values: ``true``\ , ``false``. + :paramtype allow_credentials: bool + :keyword exposed_headers: HTTP response headers to expose for cross-site requests. + :paramtype exposed_headers: list[str] + """ + super().__init__(**kwargs) + self.allowed_origins = allowed_origins + self.allowed_methods = allowed_methods + self.allowed_headers = allowed_headers + self.max_age = max_age + self.allow_credentials = allow_credentials + self.exposed_headers = exposed_headers + + +class GatewayCustomDomainProperties(_serialization.Model): + """The properties of custom domain for Spring Cloud Gateway. + + :ivar thumbprint: The thumbprint of bound certificate. + :vartype thumbprint: str + """ + + _attribute_map = { + "thumbprint": {"key": "thumbprint", "type": "str"}, + } + + def __init__(self, *, thumbprint: Optional[str] = None, **kwargs): + """ + :keyword thumbprint: The thumbprint of bound certificate. + :paramtype thumbprint: str + """ + super().__init__(**kwargs) + self.thumbprint = thumbprint + + +class GatewayCustomDomainResource(ProxyResource): + """Custom domain of the Spring Cloud Gateway. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: The properties of custom domain for Spring Cloud Gateway. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainProperties + """ + + _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": "GatewayCustomDomainProperties"}, + } + + def __init__(self, *, properties: Optional["_models.GatewayCustomDomainProperties"] = None, **kwargs): + """ + :keyword properties: The properties of custom domain for Spring Cloud Gateway. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class GatewayCustomDomainResourceCollection(_serialization.Model): + """Object that includes an array of Spring Cloud Gateway custom domain resources and a possible link for next set. + + :ivar value: Collection of Spring Cloud Gateway custom domain resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GatewayCustomDomainResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.GatewayCustomDomainResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of Spring Cloud Gateway custom domain resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GatewayInstance(_serialization.Model): + """Collection of instances belong to the Spring Cloud Gateway. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Spring Cloud Gateway instance. + :vartype name: str + :ivar status: Status of the Spring Cloud Gateway instance. + :vartype status: str + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + + +class GatewayOperatorProperties(_serialization.Model): + """Properties of the Spring Cloud Gateway Operator. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_requests: The requested resource quantity for required CPU and Memory. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayOperatorResourceRequests + :ivar instances: Collection of instances belong to Spring Cloud Gateway operator. + :vartype instances: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayInstance] + """ + + _validation = { + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, + } + + _attribute_map = { + "resource_requests": {"key": "resourceRequests", "type": "GatewayOperatorResourceRequests"}, + "instances": {"key": "instances", "type": "[GatewayInstance]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.resource_requests = None + self.instances = None + + +class GatewayOperatorResourceRequests(_serialization.Model): + """Properties of the Spring Cloud Gateway Operator. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: Cpu allocated to each Spring Cloud Gateway Operator instance. + :vartype cpu: str + :ivar memory: Memory allocated to each Spring Cloud Gateway Operator instance. + :vartype memory: str + :ivar instance_count: Instance count of the Spring Cloud Gateway Operator. + :vartype instance_count: int + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, + } + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.cpu = None + self.memory = None + self.instance_count = None + + +class GatewayProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Spring Cloud Gateway properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the Spring Cloud Gateway. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayProvisioningState + :ivar public: Indicates whether the Spring Cloud Gateway exposes endpoint. + :vartype public: bool + :ivar url: URL of the Spring Cloud Gateway, exposed when 'public' is true. + :vartype url: str + :ivar https_only: Indicate if only https is allowed. + :vartype https_only: bool + :ivar sso_properties: Single sign-on related configuration. + :vartype sso_properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SsoProperties + :ivar api_metadata_properties: API metadata property for Spring Cloud Gateway. + :vartype api_metadata_properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayApiMetadataProperties + :ivar cors_properties: Cross-Origin Resource Sharing property. + :vartype cors_properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCorsProperties + :ivar apm_types: Collection of APM type used in Spring Cloud Gateway. + :vartype apm_types: list[str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApmType] + :ivar environment_variables: Environment variables of Spring Cloud Gateway. + :vartype environment_variables: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayPropertiesEnvironmentVariables + :ivar resource_requests: The requested resource quantity for required CPU and Memory. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResourceRequests + :ivar instances: Collection of instances belong to Spring Cloud Gateway. + :vartype instances: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayInstance] + :ivar operator_properties: Properties of the Spring Cloud Gateway Operator. + :vartype operator_properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayOperatorProperties + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "url": {"readonly": True}, + "apm_types": {"unique": True}, + "instances": {"readonly": True}, + "operator_properties": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "public": {"key": "public", "type": "bool"}, + "url": {"key": "url", "type": "str"}, + "https_only": {"key": "httpsOnly", "type": "bool"}, + "sso_properties": {"key": "ssoProperties", "type": "SsoProperties"}, + "api_metadata_properties": {"key": "apiMetadataProperties", "type": "GatewayApiMetadataProperties"}, + "cors_properties": {"key": "corsProperties", "type": "GatewayCorsProperties"}, + "apm_types": {"key": "apmTypes", "type": "[str]"}, + "environment_variables": {"key": "environmentVariables", "type": "GatewayPropertiesEnvironmentVariables"}, + "resource_requests": {"key": "resourceRequests", "type": "GatewayResourceRequests"}, + "instances": {"key": "instances", "type": "[GatewayInstance]"}, + "operator_properties": {"key": "operatorProperties", "type": "GatewayOperatorProperties"}, + } + + def __init__( + self, + *, + public: bool = False, + https_only: bool = False, + sso_properties: Optional["_models.SsoProperties"] = None, + api_metadata_properties: Optional["_models.GatewayApiMetadataProperties"] = None, + cors_properties: Optional["_models.GatewayCorsProperties"] = None, + apm_types: Optional[List[Union[str, "_models.ApmType"]]] = None, + environment_variables: Optional["_models.GatewayPropertiesEnvironmentVariables"] = None, + resource_requests: Optional["_models.GatewayResourceRequests"] = None, + **kwargs + ): + """ + :keyword public: Indicates whether the Spring Cloud Gateway exposes endpoint. + :paramtype public: bool + :keyword https_only: Indicate if only https is allowed. + :paramtype https_only: bool + :keyword sso_properties: Single sign-on related configuration. + :paramtype sso_properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SsoProperties + :keyword api_metadata_properties: API metadata property for Spring Cloud Gateway. + :paramtype api_metadata_properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayApiMetadataProperties + :keyword cors_properties: Cross-Origin Resource Sharing property. + :paramtype cors_properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCorsProperties + :keyword apm_types: Collection of APM type used in Spring Cloud Gateway. + :paramtype apm_types: list[str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApmType] + :keyword environment_variables: Environment variables of Spring Cloud Gateway. + :paramtype environment_variables: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayPropertiesEnvironmentVariables + :keyword resource_requests: The requested resource quantity for required CPU and Memory. + :paramtype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResourceRequests + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.public = public + self.url = None + self.https_only = https_only + self.sso_properties = sso_properties + self.api_metadata_properties = api_metadata_properties + self.cors_properties = cors_properties + self.apm_types = apm_types + self.environment_variables = environment_variables + self.resource_requests = resource_requests + self.instances = None + self.operator_properties = None + + +class GatewayPropertiesEnvironmentVariables(_serialization.Model): + """Environment variables of Spring Cloud Gateway. + + :ivar properties: Non-sensitive properties. + :vartype properties: dict[str, str] + :ivar secrets: Sensitive properties. + :vartype secrets: dict[str, str] + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "{str}"}, + "secrets": {"key": "secrets", "type": "{str}"}, + } + + def __init__( + self, *, properties: Optional[Dict[str, str]] = None, secrets: Optional[Dict[str, str]] = None, **kwargs + ): + """ + :keyword properties: Non-sensitive properties. + :paramtype properties: dict[str, str] + :keyword secrets: Sensitive properties. + :paramtype secrets: dict[str, str] + """ + super().__init__(**kwargs) + self.properties = properties + self.secrets = secrets + + +class GatewayResource(ProxyResource): + """Spring Cloud Gateway resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Spring Cloud Gateway properties payload. + :vartype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayProperties + :ivar sku: Sku of the Spring Cloud Gateway resource. + :vartype sku: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Sku + """ + + _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": "GatewayProperties"}, + "sku": {"key": "sku", "type": "Sku"}, + } + + def __init__( + self, *, properties: Optional["_models.GatewayProperties"] = None, sku: Optional["_models.Sku"] = None, **kwargs + ): + """ + :keyword properties: Spring Cloud Gateway properties payload. + :paramtype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayProperties + :keyword sku: Sku of the Spring Cloud Gateway resource. + :paramtype sku: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Sku + """ + super().__init__(**kwargs) + self.properties = properties + self.sku = sku + + +class GatewayResourceCollection(_serialization.Model): + """Object that includes an array of gateway resources and a possible link for next set. + + :ivar value: Collection of gateway resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GatewayResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.GatewayResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of gateway resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GatewayResourceRequests(_serialization.Model): + """Resource request payload of Spring Cloud Gateway. + + :ivar cpu: Cpu allocated to each Spring Cloud Gateway instance. + :vartype cpu: str + :ivar memory: Memory allocated to each Spring Cloud Gateway instance. + :vartype memory: str + """ + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + } + + def __init__(self, *, cpu: str = "1", memory: str = "2Gi", **kwargs): + """ + :keyword cpu: Cpu allocated to each Spring Cloud Gateway instance. + :paramtype cpu: str + :keyword memory: Memory allocated to each Spring Cloud Gateway instance. + :paramtype memory: str + """ + super().__init__(**kwargs) + self.cpu = cpu + self.memory = memory + + +class GatewayRouteConfigOpenApiProperties(_serialization.Model): + """OpenAPI properties of Spring Cloud Gateway route config. + + :ivar uri: The URI of OpenAPI specification. + :vartype uri: str + """ + + _attribute_map = { + "uri": {"key": "uri", "type": "str"}, + } + + def __init__(self, *, uri: Optional[str] = None, **kwargs): + """ + :keyword uri: The URI of OpenAPI specification. + :paramtype uri: str + """ + super().__init__(**kwargs) + self.uri = uri + + +class GatewayRouteConfigProperties(_serialization.Model): + """API route config of the Spring Cloud Gateway. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the Spring Cloud Gateway route config. Known values are: + "Creating", "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayProvisioningState + :ivar app_resource_id: The resource Id of the Azure Spring Apps app, required unless route + defines ``uri``. + :vartype app_resource_id: str + :ivar open_api: OpenAPI properties of Spring Cloud Gateway route config. + :vartype open_api: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigOpenApiProperties + :ivar protocol: Protocol of routed Azure Spring Apps applications. Known values are: "HTTP" and + "HTTPS". + :vartype protocol: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigProtocol + :ivar routes: Array of API routes, each route contains properties such as ``title``\ , ``uri``\ + , ``ssoEnabled``\ , ``predicates``\ , ``filters``. + :vartype routes: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayApiRoute] + :ivar sso_enabled: Enable Single Sign-On in app level. + :vartype sso_enabled: bool + :ivar predicates: A number of conditions to evaluate a route for each request in app level. + Each predicate may be evaluated against request headers and parameter values. All of the + predicates associated with a route must evaluate to true for the route to be matched to the + request. + :vartype predicates: list[str] + :ivar filters: To modify the request before sending it to the target endpoint, or the received + response in app level. + :vartype filters: list[str] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "app_resource_id": {"key": "appResourceId", "type": "str"}, + "open_api": {"key": "openApi", "type": "GatewayRouteConfigOpenApiProperties"}, + "protocol": {"key": "protocol", "type": "str"}, + "routes": {"key": "routes", "type": "[GatewayApiRoute]"}, + "sso_enabled": {"key": "ssoEnabled", "type": "bool"}, + "predicates": {"key": "predicates", "type": "[str]"}, + "filters": {"key": "filters", "type": "[str]"}, + } + + def __init__( + self, + *, + app_resource_id: Optional[str] = None, + open_api: Optional["_models.GatewayRouteConfigOpenApiProperties"] = None, + protocol: Union[str, "_models.GatewayRouteConfigProtocol"] = "HTTP", + routes: Optional[List["_models.GatewayApiRoute"]] = None, + sso_enabled: Optional[bool] = None, + predicates: Optional[List[str]] = None, + filters: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword app_resource_id: The resource Id of the Azure Spring Apps app, required unless route + defines ``uri``. + :paramtype app_resource_id: str + :keyword open_api: OpenAPI properties of Spring Cloud Gateway route config. + :paramtype open_api: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigOpenApiProperties + :keyword protocol: Protocol of routed Azure Spring Apps applications. Known values are: "HTTP" + and "HTTPS". + :paramtype protocol: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigProtocol + :keyword routes: Array of API routes, each route contains properties such as ``title``\ , + ``uri``\ , ``ssoEnabled``\ , ``predicates``\ , ``filters``. + :paramtype routes: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayApiRoute] + :keyword sso_enabled: Enable Single Sign-On in app level. + :paramtype sso_enabled: bool + :keyword predicates: A number of conditions to evaluate a route for each request in app level. + Each predicate may be evaluated against request headers and parameter values. All of the + predicates associated with a route must evaluate to true for the route to be matched to the + request. + :paramtype predicates: list[str] + :keyword filters: To modify the request before sending it to the target endpoint, or the + received response in app level. + :paramtype filters: list[str] + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.app_resource_id = app_resource_id + self.open_api = open_api + self.protocol = protocol + self.routes = routes + self.sso_enabled = sso_enabled + self.predicates = predicates + self.filters = filters + + +class GatewayRouteConfigResource(ProxyResource): + """Spring Cloud Gateway route config resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: API route config of the Spring Cloud Gateway. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigProperties + """ + + _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": "GatewayRouteConfigProperties"}, + } + + def __init__(self, *, properties: Optional["_models.GatewayRouteConfigProperties"] = None, **kwargs): + """ + :keyword properties: API route config of the Spring Cloud Gateway. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class GatewayRouteConfigResourceCollection(_serialization.Model): + """Object that includes an array of Spring Cloud Gateway route config resources and a possible link for next set. + + :ivar value: Collection of Spring Cloud Gateway route config resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GatewayRouteConfigResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.GatewayRouteConfigResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of Spring Cloud Gateway route config resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GitPatternRepository(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Git repository property payload for config server. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name of the repository. Required. + :vartype name: str + :ivar pattern: Collection of pattern of the repository. + :vartype pattern: list[str] + :ivar uri: URI of the repository. Required. + :vartype uri: str + :ivar label: Label of the repository. + :vartype label: str + :ivar search_paths: Searching path of the repository. + :vartype search_paths: list[str] + :ivar username: Username of git repository basic auth. + :vartype username: str + :ivar password: Password of git repository basic auth. + :vartype password: str + :ivar host_key: Public sshKey of git repository. + :vartype host_key: str + :ivar host_key_algorithm: SshKey algorithm of git repository. + :vartype host_key_algorithm: str + :ivar private_key: Private sshKey algorithm of git repository. + :vartype private_key: str + :ivar strict_host_key_checking: Strict host key checking or not. + :vartype strict_host_key_checking: bool + """ + + _validation = { + "name": {"required": True}, + "uri": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "pattern": {"key": "pattern", "type": "[str]"}, + "uri": {"key": "uri", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "search_paths": {"key": "searchPaths", "type": "[str]"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "host_key": {"key": "hostKey", "type": "str"}, + "host_key_algorithm": {"key": "hostKeyAlgorithm", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "strict_host_key_checking": {"key": "strictHostKeyChecking", "type": "bool"}, + } + + def __init__( + self, + *, + name: str, + uri: str, + pattern: Optional[List[str]] = None, + label: Optional[str] = None, + search_paths: Optional[List[str]] = None, + username: Optional[str] = None, + password: Optional[str] = None, + host_key: Optional[str] = None, + host_key_algorithm: Optional[str] = None, + private_key: Optional[str] = None, + strict_host_key_checking: Optional[bool] = None, + **kwargs + ): + """ + :keyword name: Name of the repository. Required. + :paramtype name: str + :keyword pattern: Collection of pattern of the repository. + :paramtype pattern: list[str] + :keyword uri: URI of the repository. Required. + :paramtype uri: str + :keyword label: Label of the repository. + :paramtype label: str + :keyword search_paths: Searching path of the repository. + :paramtype search_paths: list[str] + :keyword username: Username of git repository basic auth. + :paramtype username: str + :keyword password: Password of git repository basic auth. + :paramtype password: str + :keyword host_key: Public sshKey of git repository. + :paramtype host_key: str + :keyword host_key_algorithm: SshKey algorithm of git repository. + :paramtype host_key_algorithm: str + :keyword private_key: Private sshKey algorithm of git repository. + :paramtype private_key: str + :keyword strict_host_key_checking: Strict host key checking or not. + :paramtype strict_host_key_checking: bool + """ + super().__init__(**kwargs) + self.name = name + self.pattern = pattern + self.uri = uri + self.label = label + self.search_paths = search_paths + self.username = username + self.password = password + self.host_key = host_key + self.host_key_algorithm = host_key_algorithm + self.private_key = private_key + self.strict_host_key_checking = strict_host_key_checking + + +class HTTPGetAction(ProbeAction): + """HTTPGetAction describes an action based on HTTP Get requests. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the action to take to perform the health check. Required. Known values + are: "HTTPGetAction", "TCPSocketAction", and "ExecAction". + :vartype type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.ProbeActionType + :ivar path: Path to access on the HTTP server. + :vartype path: str + :ivar scheme: Scheme to use for connecting to the host. Defaults to HTTP. + + Possible enum values: + + + * ``"HTTP"`` means that the scheme used will be http:// + * ``"HTTPS"`` means that the scheme used will be https://. Known values are: "HTTP" and + "HTTPS". + :vartype scheme: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.HTTPSchemeType + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "path": {"key": "path", "type": "str"}, + "scheme": {"key": "scheme", "type": "str"}, + } + + def __init__( + self, *, path: Optional[str] = None, scheme: Optional[Union[str, "_models.HTTPSchemeType"]] = None, **kwargs + ): + """ + :keyword path: Path to access on the HTTP server. + :paramtype path: str + :keyword scheme: Scheme to use for connecting to the host. Defaults to HTTP. + + Possible enum values: + + + * ``"HTTP"`` means that the scheme used will be http:// + * ``"HTTPS"`` means that the scheme used will be https://. Known values are: "HTTP" and + "HTTPS". + :paramtype scheme: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.HTTPSchemeType + """ + super().__init__(**kwargs) + self.type = "HTTPGetAction" # type: str + self.path = path + self.scheme = scheme + + +class ImageRegistryCredential(_serialization.Model): + """Credential of the image registry. + + :ivar username: The username of the image registry credential. + :vartype username: str + :ivar password: The password of the image registry credential. + :vartype password: str + """ + + _attribute_map = { + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + } + + def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs): + """ + :keyword username: The username of the image registry credential. + :paramtype username: str + :keyword password: The password of the image registry credential. + :paramtype password: str + """ + super().__init__(**kwargs) + self.username = username + self.password = password + + +class IngressConfig(_serialization.Model): + """Ingress configuration payload for Azure Spring Apps resource. + + :ivar read_timeout_in_seconds: Ingress read time out in seconds. + :vartype read_timeout_in_seconds: int + """ + + _attribute_map = { + "read_timeout_in_seconds": {"key": "readTimeoutInSeconds", "type": "int"}, + } + + def __init__(self, *, read_timeout_in_seconds: Optional[int] = None, **kwargs): + """ + :keyword read_timeout_in_seconds: Ingress read time out in seconds. + :paramtype read_timeout_in_seconds: int + """ + super().__init__(**kwargs) + self.read_timeout_in_seconds = read_timeout_in_seconds + + +class IngressSettings(_serialization.Model): + """App ingress settings payload. + + :ivar read_timeout_in_seconds: Ingress read time out in seconds. + :vartype read_timeout_in_seconds: int + :ivar send_timeout_in_seconds: Ingress send time out in seconds. + :vartype send_timeout_in_seconds: int + :ivar session_affinity: Type of the affinity, set this to Cookie to enable session affinity. + Known values are: "Cookie" and "None". + :vartype session_affinity: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.SessionAffinity + :ivar session_cookie_max_age: Time in seconds until the cookie expires. + :vartype session_cookie_max_age: int + :ivar backend_protocol: How ingress should communicate with this app backend service. Known + values are: "GRPC" and "Default". + :vartype backend_protocol: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BackendProtocol + :ivar client_auth: Client-Certification Authentication. + :vartype client_auth: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.IngressSettingsClientAuth + """ + + _attribute_map = { + "read_timeout_in_seconds": {"key": "readTimeoutInSeconds", "type": "int"}, + "send_timeout_in_seconds": {"key": "sendTimeoutInSeconds", "type": "int"}, + "session_affinity": {"key": "sessionAffinity", "type": "str"}, + "session_cookie_max_age": {"key": "sessionCookieMaxAge", "type": "int"}, + "backend_protocol": {"key": "backendProtocol", "type": "str"}, + "client_auth": {"key": "clientAuth", "type": "IngressSettingsClientAuth"}, + } + + def __init__( + self, + *, + read_timeout_in_seconds: Optional[int] = None, + send_timeout_in_seconds: Optional[int] = None, + session_affinity: Optional[Union[str, "_models.SessionAffinity"]] = None, + session_cookie_max_age: Optional[int] = None, + backend_protocol: Optional[Union[str, "_models.BackendProtocol"]] = None, + client_auth: Optional["_models.IngressSettingsClientAuth"] = None, + **kwargs + ): + """ + :keyword read_timeout_in_seconds: Ingress read time out in seconds. + :paramtype read_timeout_in_seconds: int + :keyword send_timeout_in_seconds: Ingress send time out in seconds. + :paramtype send_timeout_in_seconds: int + :keyword session_affinity: Type of the affinity, set this to Cookie to enable session affinity. + Known values are: "Cookie" and "None". + :paramtype session_affinity: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.SessionAffinity + :keyword session_cookie_max_age: Time in seconds until the cookie expires. + :paramtype session_cookie_max_age: int + :keyword backend_protocol: How ingress should communicate with this app backend service. Known + values are: "GRPC" and "Default". + :paramtype backend_protocol: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BackendProtocol + :keyword client_auth: Client-Certification Authentication. + :paramtype client_auth: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.IngressSettingsClientAuth + """ + super().__init__(**kwargs) + self.read_timeout_in_seconds = read_timeout_in_seconds + self.send_timeout_in_seconds = send_timeout_in_seconds + self.session_affinity = session_affinity + self.session_cookie_max_age = session_cookie_max_age + self.backend_protocol = backend_protocol + self.client_auth = client_auth + + +class IngressSettingsClientAuth(_serialization.Model): + """Client-Certification Authentication. + + :ivar certificates: Collection of certificate resource id. + :vartype certificates: list[str] + """ + + _attribute_map = { + "certificates": {"key": "certificates", "type": "[str]"}, + } + + def __init__(self, *, certificates: Optional[List[str]] = None, **kwargs): + """ + :keyword certificates: Collection of certificate resource id. + :paramtype certificates: list[str] + """ + super().__init__(**kwargs) + self.certificates = certificates + + +class UploadedUserSourceInfo(UserSourceInfo): + """Source with uploaded location. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + JarUploadedUserSourceInfo, NetCoreZipUploadedUserSourceInfo, SourceUploadedUserSourceInfo + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the source uploaded. Required. + :vartype type: str + :ivar version: Version of the source. + :vartype version: str + :ivar relative_path: Relative path of the storage which stores the source. + :vartype relative_path: str + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + } + + _subtype_map = { + "type": { + "Jar": "JarUploadedUserSourceInfo", + "NetCoreZip": "NetCoreZipUploadedUserSourceInfo", + "Source": "SourceUploadedUserSourceInfo", + } + } + + def __init__(self, *, version: Optional[str] = None, relative_path: Optional[str] = None, **kwargs): + """ + :keyword version: Version of the source. + :paramtype version: str + :keyword relative_path: Relative path of the storage which stores the source. + :paramtype relative_path: str + """ + super().__init__(version=version, **kwargs) + self.type = "UploadedUserSourceInfo" # type: str + self.relative_path = relative_path + + +class JarUploadedUserSourceInfo(UploadedUserSourceInfo): + """Uploaded Jar binary for a deployment. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the source uploaded. Required. + :vartype type: str + :ivar version: Version of the source. + :vartype version: str + :ivar relative_path: Relative path of the storage which stores the source. + :vartype relative_path: str + :ivar runtime_version: Runtime version of the Jar file. + :vartype runtime_version: str + :ivar jvm_options: JVM parameter. + :vartype jvm_options: str + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, + "jvm_options": {"key": "jvmOptions", "type": "str"}, + } + + def __init__( + self, + *, + version: Optional[str] = None, + relative_path: Optional[str] = None, + runtime_version: Optional[str] = None, + jvm_options: Optional[str] = None, + **kwargs + ): + """ + :keyword version: Version of the source. + :paramtype version: str + :keyword relative_path: Relative path of the storage which stores the source. + :paramtype relative_path: str + :keyword runtime_version: Runtime version of the Jar file. + :paramtype runtime_version: str + :keyword jvm_options: JVM parameter. + :paramtype jvm_options: str + """ + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "Jar" # type: str + self.runtime_version = runtime_version + self.jvm_options = jvm_options + + +class KeyVaultCertificateProperties(CertificateProperties): # pylint: disable=too-many-instance-attributes + """Properties of certificate imported from key vault. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the certificate source. Required. + :vartype type: str + :ivar thumbprint: The thumbprint of certificate. + :vartype thumbprint: str + :ivar issuer: The issuer of certificate. + :vartype issuer: str + :ivar issued_date: The issue date of certificate. + :vartype issued_date: str + :ivar expiration_date: The expiration date of certificate. + :vartype expiration_date: str + :ivar activate_date: The activate date of certificate. + :vartype activate_date: str + :ivar subject_name: The subject name of certificate. + :vartype subject_name: str + :ivar dns_names: The domain list of certificate. + :vartype dns_names: list[str] + :ivar provisioning_state: Provisioning state of the Certificate. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResourceProvisioningState + :ivar vault_uri: The vault uri of user key vault. Required. + :vartype vault_uri: str + :ivar key_vault_cert_name: The certificate name of key vault. Required. + :vartype key_vault_cert_name: str + :ivar cert_version: The certificate version of key vault. + :vartype cert_version: str + :ivar exclude_private_key: Optional. If set to true, it will not import private key from key + vault. + :vartype exclude_private_key: bool + """ + + _validation = { + "type": {"required": True}, + "thumbprint": {"readonly": True}, + "issuer": {"readonly": True}, + "issued_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "activate_date": {"readonly": True}, + "subject_name": {"readonly": True}, + "dns_names": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "vault_uri": {"required": True}, + "key_vault_cert_name": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "issued_date": {"key": "issuedDate", "type": "str"}, + "expiration_date": {"key": "expirationDate", "type": "str"}, + "activate_date": {"key": "activateDate", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "dns_names": {"key": "dnsNames", "type": "[str]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "vault_uri": {"key": "vaultUri", "type": "str"}, + "key_vault_cert_name": {"key": "keyVaultCertName", "type": "str"}, + "cert_version": {"key": "certVersion", "type": "str"}, + "exclude_private_key": {"key": "excludePrivateKey", "type": "bool"}, + } + + def __init__( + self, + *, + vault_uri: str, + key_vault_cert_name: str, + cert_version: Optional[str] = None, + exclude_private_key: bool = False, + **kwargs + ): + """ + :keyword vault_uri: The vault uri of user key vault. Required. + :paramtype vault_uri: str + :keyword key_vault_cert_name: The certificate name of key vault. Required. + :paramtype key_vault_cert_name: str + :keyword cert_version: The certificate version of key vault. + :paramtype cert_version: str + :keyword exclude_private_key: Optional. If set to true, it will not import private key from key + vault. + :paramtype exclude_private_key: bool + """ + super().__init__(**kwargs) + self.type = "KeyVaultCertificate" # type: str + self.vault_uri = vault_uri + self.key_vault_cert_name = key_vault_cert_name + self.cert_version = cert_version + self.exclude_private_key = exclude_private_key + + +class LoadedCertificate(_serialization.Model): + """Loaded certificate payload. + + All required parameters must be populated in order to send to Azure. + + :ivar resource_id: Resource Id of loaded certificate. Required. + :vartype resource_id: str + :ivar load_trust_store: Indicate whether the certificate will be loaded into default trust + store, only work for Java runtime. + :vartype load_trust_store: bool + """ + + _validation = { + "resource_id": {"required": True}, + } + + _attribute_map = { + "resource_id": {"key": "resourceId", "type": "str"}, + "load_trust_store": {"key": "loadTrustStore", "type": "bool"}, + } + + def __init__(self, *, resource_id: str, load_trust_store: bool = False, **kwargs): + """ + :keyword resource_id: Resource Id of loaded certificate. Required. + :paramtype resource_id: str + :keyword load_trust_store: Indicate whether the certificate will be loaded into default trust + store, only work for Java runtime. + :paramtype load_trust_store: bool + """ + super().__init__(**kwargs) + self.resource_id = resource_id + self.load_trust_store = load_trust_store + + +class LogFileUrlResponse(_serialization.Model): + """Log file URL payload. + + All required parameters must be populated in order to send to Azure. + + :ivar url: URL of the log file. Required. + :vartype url: str + """ + + _validation = { + "url": {"required": True}, + } + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + } + + def __init__(self, *, url: str, **kwargs): + """ + :keyword url: URL of the log file. Required. + :paramtype url: str + """ + super().__init__(**kwargs) + self.url = url + + +class LogSpecification(_serialization.Model): + """Specifications of the Log for Azure Monitoring. + + :ivar name: Name of the log. + :vartype name: str + :ivar display_name: Localized friendly display name of the log. + :vartype display_name: str + :ivar blob_duration: Blob duration of the log. + :vartype blob_duration: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + blob_duration: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Name of the log. + :paramtype name: str + :keyword display_name: Localized friendly display name of the log. + :paramtype display_name: str + :keyword blob_duration: Blob duration of the log. + :paramtype blob_duration: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.blob_duration = blob_duration + + +class ManagedIdentityProperties(_serialization.Model): + """Managed identity properties retrieved from ARM request headers. + + :ivar type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.ManagedIdentityType + :ivar principal_id: Principal Id of system-assigned managed identity. + :vartype principal_id: str + :ivar tenant_id: Tenant Id of system-assigned managed identity. + :vartype tenant_id: str + :ivar user_assigned_identities: Properties of user-assigned managed identities. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.appplatform.v2022_11_01_preview.models.UserAssignedManagedIdentity] + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedManagedIdentity}"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, + principal_id: Optional[str] = None, + tenant_id: Optional[str] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedManagedIdentity"]] = None, + **kwargs + ): + """ + :keyword type: Type of the managed identity. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". + :paramtype type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.ManagedIdentityType + :keyword principal_id: Principal Id of system-assigned managed identity. + :paramtype principal_id: str + :keyword tenant_id: Tenant Id of system-assigned managed identity. + :paramtype tenant_id: str + :keyword user_assigned_identities: Properties of user-assigned managed identities. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.appplatform.v2022_11_01_preview.models.UserAssignedManagedIdentity] + """ + super().__init__(**kwargs) + self.type = type + self.principal_id = principal_id + self.tenant_id = tenant_id + self.user_assigned_identities = user_assigned_identities + + +class MarketplaceResource(_serialization.Model): + """Purchasing 3rd Party product for one Azure Spring Apps instance. + + :ivar plan: The plan id of the 3rd Party Artifact that is being procured. + :vartype plan: str + :ivar publisher: The publisher id of the 3rd Party Artifact that is being bought. + :vartype publisher: str + :ivar product: The 3rd Party artifact that is being procured. + :vartype product: str + """ + + _attribute_map = { + "plan": {"key": "plan", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + } + + def __init__( + self, *, plan: Optional[str] = None, publisher: Optional[str] = None, product: Optional[str] = None, **kwargs + ): + """ + :keyword plan: The plan id of the 3rd Party Artifact that is being procured. + :paramtype plan: str + :keyword publisher: The publisher id of the 3rd Party Artifact that is being bought. + :paramtype publisher: str + :keyword product: The 3rd Party artifact that is being procured. + :paramtype product: str + """ + super().__init__(**kwargs) + self.plan = plan + self.publisher = publisher + self.product = product + + +class MetricDimension(_serialization.Model): + """Specifications of the Dimension of metrics. + + :ivar name: Name of the dimension. + :vartype name: str + :ivar display_name: Localized friendly display name of the dimension. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: Whether this dimension should be included for the Shoebox + export scenario. + :vartype to_be_exported_for_shoebox: bool + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + to_be_exported_for_shoebox: Optional[bool] = None, + **kwargs + ): + """ + :keyword name: Name of the dimension. + :paramtype name: str + :keyword display_name: Localized friendly display name of the dimension. + :paramtype display_name: str + :keyword to_be_exported_for_shoebox: Whether this dimension should be included for the Shoebox + export scenario. + :paramtype to_be_exported_for_shoebox: bool + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.to_be_exported_for_shoebox = to_be_exported_for_shoebox + + +class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Specifications of the Metrics for Azure Monitoring. + + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Localized friendly display name of the metric. + :vartype display_name: str + :ivar display_description: Localized friendly description of the metric. + :vartype display_description: str + :ivar unit: Unit that makes sense for the metric. + :vartype unit: str + :ivar category: Name of the metric category that the metric belongs to. A metric can only + belong to a single category. + :vartype category: str + :ivar aggregation_type: Only provide one value for this field. Valid values: Average, Minimum, + Maximum, Total, Count. + :vartype aggregation_type: str + :ivar supported_aggregation_types: Supported aggregation types. + :vartype supported_aggregation_types: list[str] + :ivar supported_time_grain_types: Supported time grain types. + :vartype supported_time_grain_types: list[str] + :ivar fill_gap_with_zero: Optional. If set to true, then zero will be returned for time + duration where no metric is emitted/published. + :vartype fill_gap_with_zero: bool + :ivar dimensions: Dimensions of the metric. + :vartype dimensions: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.MetricDimension] + :ivar source_mdm_namespace: Name of the MDM namespace. Optional. + :vartype source_mdm_namespace: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "source_mdm_namespace": {"key": "sourceMdmNamespace", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + unit: Optional[str] = None, + category: Optional[str] = None, + aggregation_type: Optional[str] = None, + supported_aggregation_types: Optional[List[str]] = None, + supported_time_grain_types: Optional[List[str]] = None, + fill_gap_with_zero: Optional[bool] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, + source_mdm_namespace: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Name of the metric. + :paramtype name: str + :keyword display_name: Localized friendly display name of the metric. + :paramtype display_name: str + :keyword display_description: Localized friendly description of the metric. + :paramtype display_description: str + :keyword unit: Unit that makes sense for the metric. + :paramtype unit: str + :keyword category: Name of the metric category that the metric belongs to. A metric can only + belong to a single category. + :paramtype category: str + :keyword aggregation_type: Only provide one value for this field. Valid values: Average, + Minimum, Maximum, Total, Count. + :paramtype aggregation_type: str + :keyword supported_aggregation_types: Supported aggregation types. + :paramtype supported_aggregation_types: list[str] + :keyword supported_time_grain_types: Supported time grain types. + :paramtype supported_time_grain_types: list[str] + :keyword fill_gap_with_zero: Optional. If set to true, then zero will be returned for time + duration where no metric is emitted/published. + :paramtype fill_gap_with_zero: bool + :keyword dimensions: Dimensions of the metric. + :paramtype dimensions: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.MetricDimension] + :keyword source_mdm_namespace: Name of the MDM namespace. Optional. + :paramtype source_mdm_namespace: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.display_description = display_description + self.unit = unit + self.category = category + self.aggregation_type = aggregation_type + self.supported_aggregation_types = supported_aggregation_types + self.supported_time_grain_types = supported_time_grain_types + self.fill_gap_with_zero = fill_gap_with_zero + self.dimensions = dimensions + self.source_mdm_namespace = source_mdm_namespace + + +class MonitoringSettingProperties(_serialization.Model): + """Monitoring Setting properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the Monitoring Setting. Known values are: "NotAvailable", + "Failed", "Succeeded", and "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingState + :ivar error: Error when apply Monitoring Setting changes. + :vartype error: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Error + :ivar trace_enabled: Indicates whether enable the trace functionality, which will be deprecated + since api version 2020-11-01-preview. Please leverage appInsightsInstrumentationKey to indicate + if monitoringSettings enabled or not. + :vartype trace_enabled: bool + :ivar app_insights_instrumentation_key: Target application insight instrumentation key, null or + whitespace include empty will disable monitoringSettings. + :vartype app_insights_instrumentation_key: str + :ivar app_insights_sampling_rate: Indicates the sampling rate of application insight agent, + should be in range [0.0, 100.0]. + :vartype app_insights_sampling_rate: float + :ivar app_insights_agent_versions: Indicates the versions of application insight agent. + :vartype app_insights_agent_versions: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationInsightsAgentVersions + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "app_insights_sampling_rate": {"maximum": 100, "minimum": 0}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "error": {"key": "error", "type": "Error"}, + "trace_enabled": {"key": "traceEnabled", "type": "bool"}, + "app_insights_instrumentation_key": {"key": "appInsightsInstrumentationKey", "type": "str"}, + "app_insights_sampling_rate": {"key": "appInsightsSamplingRate", "type": "float"}, + "app_insights_agent_versions": {"key": "appInsightsAgentVersions", "type": "ApplicationInsightsAgentVersions"}, + } + + def __init__( + self, + *, + error: Optional["_models.Error"] = None, + trace_enabled: Optional[bool] = None, + app_insights_instrumentation_key: Optional[str] = None, + app_insights_sampling_rate: Optional[float] = None, + app_insights_agent_versions: Optional["_models.ApplicationInsightsAgentVersions"] = None, + **kwargs + ): + """ + :keyword error: Error when apply Monitoring Setting changes. + :paramtype error: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Error + :keyword trace_enabled: Indicates whether enable the trace functionality, which will be + deprecated since api version 2020-11-01-preview. Please leverage appInsightsInstrumentationKey + to indicate if monitoringSettings enabled or not. + :paramtype trace_enabled: bool + :keyword app_insights_instrumentation_key: Target application insight instrumentation key, null + or whitespace include empty will disable monitoringSettings. + :paramtype app_insights_instrumentation_key: str + :keyword app_insights_sampling_rate: Indicates the sampling rate of application insight agent, + should be in range [0.0, 100.0]. + :paramtype app_insights_sampling_rate: float + :keyword app_insights_agent_versions: Indicates the versions of application insight agent. + :paramtype app_insights_agent_versions: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationInsightsAgentVersions + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.error = error + self.trace_enabled = trace_enabled + self.app_insights_instrumentation_key = app_insights_instrumentation_key + self.app_insights_sampling_rate = app_insights_sampling_rate + self.app_insights_agent_versions = app_insights_agent_versions + + +class MonitoringSettingResource(ProxyResource): + """Monitoring Setting resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Properties of the Monitoring Setting resource. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingProperties + """ + + _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": "MonitoringSettingProperties"}, + } + + def __init__(self, *, properties: Optional["_models.MonitoringSettingProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the Monitoring Setting resource. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class NameAvailability(_serialization.Model): + """Name availability result payload. + + :ivar name_available: Indicates whether the name is available. + :vartype name_available: bool + :ivar reason: Reason why the name is not available. + :vartype reason: str + :ivar message: Message why the name is not available. + :vartype message: str + """ + + _attribute_map = { + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__( + self, + *, + name_available: Optional[bool] = None, + reason: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword name_available: Indicates whether the name is available. + :paramtype name_available: bool + :keyword reason: Reason why the name is not available. + :paramtype reason: str + :keyword message: Message why the name is not available. + :paramtype message: str + """ + super().__init__(**kwargs) + self.name_available = name_available + self.reason = reason + self.message = message + + +class NameAvailabilityParameters(_serialization.Model): + """Name availability parameters payload. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the resource to check name availability. Required. + :vartype type: str + :ivar name: Name to be checked. Required. + :vartype name: str + """ + + _validation = { + "type": {"required": True}, + "name": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, type: str, name: str, **kwargs): + """ + :keyword type: Type of the resource to check name availability. Required. + :paramtype type: str + :keyword name: Name to be checked. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.type = type + self.name = name + + +class NetCoreZipUploadedUserSourceInfo(UploadedUserSourceInfo): + """Uploaded Jar binary for a deployment. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the source uploaded. Required. + :vartype type: str + :ivar version: Version of the source. + :vartype version: str + :ivar relative_path: Relative path of the storage which stores the source. + :vartype relative_path: str + :ivar net_core_main_entry_path: The path to the .NET executable relative to zip root. + :vartype net_core_main_entry_path: str + :ivar runtime_version: Runtime version of the .Net file. + :vartype runtime_version: str + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "net_core_main_entry_path": {"key": "netCoreMainEntryPath", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, + } + + def __init__( + self, + *, + version: Optional[str] = None, + relative_path: Optional[str] = None, + net_core_main_entry_path: Optional[str] = None, + runtime_version: Optional[str] = None, + **kwargs + ): + """ + :keyword version: Version of the source. + :paramtype version: str + :keyword relative_path: Relative path of the storage which stores the source. + :paramtype relative_path: str + :keyword net_core_main_entry_path: The path to the .NET executable relative to zip root. + :paramtype net_core_main_entry_path: str + :keyword runtime_version: Runtime version of the .Net file. + :paramtype runtime_version: str + """ + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "NetCoreZip" # type: str + self.net_core_main_entry_path = net_core_main_entry_path + self.runtime_version = runtime_version + + +class NetworkProfile(_serialization.Model): + """Service network profile payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar service_runtime_subnet_id: Fully qualified resource Id of the subnet to host Azure Spring + Apps Service Runtime. + :vartype service_runtime_subnet_id: str + :ivar app_subnet_id: Fully qualified resource Id of the subnet to host customer apps in Azure + Spring Apps. + :vartype app_subnet_id: str + :ivar service_cidr: Azure Spring Apps service reserved CIDR. + :vartype service_cidr: str + :ivar service_runtime_network_resource_group: Name of the resource group containing network + resources of Azure Spring Apps Service Runtime. + :vartype service_runtime_network_resource_group: str + :ivar app_network_resource_group: Name of the resource group containing network resources for + customer apps in Azure Spring Apps. + :vartype app_network_resource_group: str + :ivar outbound_i_ps: Desired outbound IP resources for Azure Spring Apps resource. + :vartype outbound_i_ps: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.NetworkProfileOutboundIPs + :ivar required_traffics: Required inbound or outbound traffics for Azure Spring Apps resource. + :vartype required_traffics: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.RequiredTraffic] + :ivar ingress_config: Ingress configuration payload for Azure Spring Apps resource. + :vartype ingress_config: ~azure.mgmt.appplatform.v2022_11_01_preview.models.IngressConfig + :ivar outbound_type: The egress traffic type of Azure Spring Apps VNet instances. + :vartype outbound_type: str + """ + + _validation = { + "outbound_i_ps": {"readonly": True}, + "required_traffics": {"readonly": True}, + } + + _attribute_map = { + "service_runtime_subnet_id": {"key": "serviceRuntimeSubnetId", "type": "str"}, + "app_subnet_id": {"key": "appSubnetId", "type": "str"}, + "service_cidr": {"key": "serviceCidr", "type": "str"}, + "service_runtime_network_resource_group": {"key": "serviceRuntimeNetworkResourceGroup", "type": "str"}, + "app_network_resource_group": {"key": "appNetworkResourceGroup", "type": "str"}, + "outbound_i_ps": {"key": "outboundIPs", "type": "NetworkProfileOutboundIPs"}, + "required_traffics": {"key": "requiredTraffics", "type": "[RequiredTraffic]"}, + "ingress_config": {"key": "ingressConfig", "type": "IngressConfig"}, + "outbound_type": {"key": "outboundType", "type": "str"}, + } + + def __init__( + self, + *, + service_runtime_subnet_id: Optional[str] = None, + app_subnet_id: Optional[str] = None, + service_cidr: Optional[str] = None, + service_runtime_network_resource_group: Optional[str] = None, + app_network_resource_group: Optional[str] = None, + ingress_config: Optional["_models.IngressConfig"] = None, + outbound_type: Optional[str] = None, + **kwargs + ): + """ + :keyword service_runtime_subnet_id: Fully qualified resource Id of the subnet to host Azure + Spring Apps Service Runtime. + :paramtype service_runtime_subnet_id: str + :keyword app_subnet_id: Fully qualified resource Id of the subnet to host customer apps in + Azure Spring Apps. + :paramtype app_subnet_id: str + :keyword service_cidr: Azure Spring Apps service reserved CIDR. + :paramtype service_cidr: str + :keyword service_runtime_network_resource_group: Name of the resource group containing network + resources of Azure Spring Apps Service Runtime. + :paramtype service_runtime_network_resource_group: str + :keyword app_network_resource_group: Name of the resource group containing network resources + for customer apps in Azure Spring Apps. + :paramtype app_network_resource_group: str + :keyword ingress_config: Ingress configuration payload for Azure Spring Apps resource. + :paramtype ingress_config: ~azure.mgmt.appplatform.v2022_11_01_preview.models.IngressConfig + :keyword outbound_type: The egress traffic type of Azure Spring Apps VNet instances. + :paramtype outbound_type: str + """ + super().__init__(**kwargs) + self.service_runtime_subnet_id = service_runtime_subnet_id + self.app_subnet_id = app_subnet_id + self.service_cidr = service_cidr + self.service_runtime_network_resource_group = service_runtime_network_resource_group + self.app_network_resource_group = app_network_resource_group + self.outbound_i_ps = None + self.required_traffics = None + self.ingress_config = ingress_config + self.outbound_type = outbound_type + + +class NetworkProfileOutboundIPs(_serialization.Model): + """Desired outbound IP resources for Azure Spring Apps resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar public_i_ps: A list of public IP addresses. + :vartype public_i_ps: list[str] + """ + + _validation = { + "public_i_ps": {"readonly": True}, + } + + _attribute_map = { + "public_i_ps": {"key": "publicIPs", "type": "[str]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.public_i_ps = None + + +class OperationDetail(_serialization.Model): + """Operation detail payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the operation. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: Display of the operation. + :vartype display: ~azure.mgmt.appplatform.v2022_11_01_preview.models.OperationDisplay + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.ActionType + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar properties: Properties of the operation. + :vartype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.OperationProperties + """ + + _validation = { + "action_type": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "action_type": {"key": "actionType", "type": "str"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "OperationProperties"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[bool] = None, + display: Optional["_models.OperationDisplay"] = None, + origin: Optional[str] = None, + properties: Optional["_models.OperationProperties"] = None, + **kwargs + ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: Display of the operation. + :paramtype display: ~azure.mgmt.appplatform.v2022_11_01_preview.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword properties: Properties of the operation. + :paramtype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.OperationProperties + """ + super().__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + self.action_type = None + self.origin = origin + self.properties = properties + + +class OperationDisplay(_serialization.Model): + """Operation display payload. + + :ivar provider: Resource provider of the operation. + :vartype provider: str + :ivar resource: Resource of the operation. + :vartype resource: str + :ivar operation: Localized friendly name for the operation. + :vartype operation: str + :ivar description: Localized friendly description for the operation. + :vartype description: str + """ + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Resource provider of the operation. + :paramtype provider: str + :keyword resource: Resource of the operation. + :paramtype resource: str + :keyword operation: Localized friendly name for the operation. + :paramtype operation: str + :keyword description: Localized friendly description for the operation. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationProperties(_serialization.Model): + """Extra Operation properties. + + :ivar service_specification: Service specifications of the operation. + :vartype service_specification: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceSpecification + """ + + _attribute_map = { + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, + } + + def __init__(self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs): + """ + :keyword service_specification: Service specifications of the operation. + :paramtype service_specification: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceSpecification + """ + super().__init__(**kwargs) + self.service_specification = service_specification + + +class PersistentDisk(_serialization.Model): + """Persistent disk payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar size_in_gb: Size of the persistent disk in GB. + :vartype size_in_gb: int + :ivar used_in_gb: Size of the used persistent disk in GB. + :vartype used_in_gb: int + :ivar mount_path: Mount path of the persistent disk. + :vartype mount_path: str + """ + + _validation = { + "size_in_gb": {"maximum": 50, "minimum": 0}, + "used_in_gb": {"readonly": True, "maximum": 50, "minimum": 0}, + } + + _attribute_map = { + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "used_in_gb": {"key": "usedInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, + } + + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: Optional[str] = None, **kwargs): + """ + :keyword size_in_gb: Size of the persistent disk in GB. + :paramtype size_in_gb: int + :keyword mount_path: Mount path of the persistent disk. + :paramtype mount_path: str + """ + super().__init__(**kwargs) + self.size_in_gb = size_in_gb + self.used_in_gb = None + self.mount_path = mount_path + + +class PredefinedAcceleratorProperties(_serialization.Model): + """Predefined accelerator properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Provisioning state of the predefined accelerator. Known values are: + "Creating", "Updating", "Succeeded", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.PredefinedAcceleratorProvisioningState + :ivar display_name: + :vartype display_name: str + :ivar description: + :vartype description: str + :ivar icon_url: + :vartype icon_url: str + :ivar accelerator_tags: + :vartype accelerator_tags: list[str] + :ivar state: State of the predefined accelerator. Known values are: "Enabled" and "Disabled". + :vartype state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.PredefinedAcceleratorState + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "icon_url": {"readonly": True}, + "accelerator_tags": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "icon_url": {"key": "iconUrl", "type": "str"}, + "accelerator_tags": {"key": "acceleratorTags", "type": "[str]"}, + "state": {"key": "state", "type": "str"}, + } + + def __init__(self, *, state: Union[str, "_models.PredefinedAcceleratorState"] = "Enabled", **kwargs): + """ + :keyword state: State of the predefined accelerator. Known values are: "Enabled" and + "Disabled". + :paramtype state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.PredefinedAcceleratorState + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.display_name = None + self.description = None + self.icon_url = None + self.accelerator_tags = None + self.state = state + + +class PredefinedAcceleratorResource(ProxyResource): + """Predefined accelerator resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Predefined accelerator properties payload. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.PredefinedAcceleratorProperties + :ivar sku: Sku of the predefined accelerator resource. + :vartype sku: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Sku + """ + + _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": "PredefinedAcceleratorProperties"}, + "sku": {"key": "sku", "type": "Sku"}, + } + + def __init__( + self, + *, + properties: Optional["_models.PredefinedAcceleratorProperties"] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword properties: Predefined accelerator properties payload. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.PredefinedAcceleratorProperties + :keyword sku: Sku of the predefined accelerator resource. + :paramtype sku: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Sku + """ + super().__init__(**kwargs) + self.properties = properties + self.sku = sku + + +class PredefinedAcceleratorResourceCollection(_serialization.Model): + """PredefinedAcceleratorResourceCollection. + + :ivar value: + :vartype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.PredefinedAcceleratorResource] + :ivar next_link: + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PredefinedAcceleratorResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.PredefinedAcceleratorResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: + :paramtype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.PredefinedAcceleratorResource] + :keyword next_link: + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Probe(_serialization.Model): + """Probe describes a health check to be performed against an App Instance to determine whether it is alive or ready to receive traffic. + + All required parameters must be populated in order to send to Azure. + + :ivar probe_action: The action of the probe. + :vartype probe_action: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ProbeAction + :ivar disable_probe: Indicate whether the probe is disabled. Required. + :vartype disable_probe: bool + :ivar initial_delay_seconds: Number of seconds after the App Instance has started before probes + are initiated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :vartype initial_delay_seconds: int + :ivar period_seconds: How often (in seconds) to perform the probe. Minimum value is 1. + :vartype period_seconds: int + :ivar timeout_seconds: Number of seconds after which the probe times out. Minimum value is 1. + :vartype timeout_seconds: int + :ivar failure_threshold: Minimum consecutive failures for the probe to be considered failed + after having succeeded. Minimum value is 1. + :vartype failure_threshold: int + :ivar success_threshold: Minimum consecutive successes for the probe to be considered + successful after having failed. Must be 1 for liveness and startup. Minimum value is 1. + :vartype success_threshold: int + """ + + _validation = { + "disable_probe": {"required": True}, + } + + _attribute_map = { + "probe_action": {"key": "probeAction", "type": "ProbeAction"}, + "disable_probe": {"key": "disableProbe", "type": "bool"}, + "initial_delay_seconds": {"key": "initialDelaySeconds", "type": "int"}, + "period_seconds": {"key": "periodSeconds", "type": "int"}, + "timeout_seconds": {"key": "timeoutSeconds", "type": "int"}, + "failure_threshold": {"key": "failureThreshold", "type": "int"}, + "success_threshold": {"key": "successThreshold", "type": "int"}, + } + + def __init__( + self, + *, + disable_probe: bool = False, + probe_action: Optional["_models.ProbeAction"] = None, + initial_delay_seconds: Optional[int] = None, + period_seconds: Optional[int] = None, + timeout_seconds: Optional[int] = None, + failure_threshold: Optional[int] = None, + success_threshold: Optional[int] = None, + **kwargs + ): + """ + :keyword probe_action: The action of the probe. + :paramtype probe_action: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ProbeAction + :keyword disable_probe: Indicate whether the probe is disabled. Required. + :paramtype disable_probe: bool + :keyword initial_delay_seconds: Number of seconds after the App Instance has started before + probes are initiated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes. + :paramtype initial_delay_seconds: int + :keyword period_seconds: How often (in seconds) to perform the probe. Minimum value is 1. + :paramtype period_seconds: int + :keyword timeout_seconds: Number of seconds after which the probe times out. Minimum value is + 1. + :paramtype timeout_seconds: int + :keyword failure_threshold: Minimum consecutive failures for the probe to be considered failed + after having succeeded. Minimum value is 1. + :paramtype failure_threshold: int + :keyword success_threshold: Minimum consecutive successes for the probe to be considered + successful after having failed. Must be 1 for liveness and startup. Minimum value is 1. + :paramtype success_threshold: int + """ + super().__init__(**kwargs) + self.probe_action = probe_action + self.disable_probe = disable_probe + self.initial_delay_seconds = initial_delay_seconds + self.period_seconds = period_seconds + self.timeout_seconds = timeout_seconds + self.failure_threshold = failure_threshold + self.success_threshold = success_threshold + + +class RegenerateTestKeyRequestPayload(_serialization.Model): + """Regenerate test key request payload. + + All required parameters must be populated in order to send to Azure. + + :ivar key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". + :vartype key_type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.TestKeyType + """ + + _validation = { + "key_type": {"required": True}, + } + + _attribute_map = { + "key_type": {"key": "keyType", "type": "str"}, + } + + def __init__(self, *, key_type: Union[str, "_models.TestKeyType"], **kwargs): + """ + :keyword key_type: Type of the test key. Required. Known values are: "Primary" and "Secondary". + :paramtype key_type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.TestKeyType + """ + super().__init__(**kwargs) + self.key_type = key_type + + +class RemoteDebugging(_serialization.Model): + """Remote debugging config. + + :ivar port: Application debugging port. + :vartype port: int + :ivar enabled: Indicate if remote debugging is enabled. + :vartype enabled: bool + """ + + _attribute_map = { + "port": {"key": "port", "type": "int"}, + "enabled": {"key": "enabled", "type": "bool"}, + } + + def __init__(self, *, port: Optional[int] = None, enabled: Optional[bool] = None, **kwargs): + """ + :keyword port: Application debugging port. + :paramtype port: int + :keyword enabled: Indicate if remote debugging is enabled. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.port = port + self.enabled = enabled + + +class RemoteDebuggingPayload(_serialization.Model): + """Remote debugging payload. + + :ivar port: Application debugging port. + :vartype port: int + """ + + _attribute_map = { + "port": {"key": "port", "type": "int"}, + } + + def __init__(self, *, port: Optional[int] = None, **kwargs): + """ + :keyword port: Application debugging port. + :paramtype port: int + """ + super().__init__(**kwargs) + self.port = port + + +class RequiredTraffic(_serialization.Model): + """Required inbound or outbound traffic for Azure Spring Apps resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar protocol: The protocol of required traffic. + :vartype protocol: str + :ivar port: The port of required traffic. + :vartype port: int + :ivar ips: The ip list of required traffic. + :vartype ips: list[str] + :ivar fqdns: The FQDN list of required traffic. + :vartype fqdns: list[str] + :ivar direction: The direction of required traffic. Known values are: "Inbound" and "Outbound". + :vartype direction: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.TrafficDirection + """ + + _validation = { + "protocol": {"readonly": True}, + "port": {"readonly": True}, + "ips": {"readonly": True}, + "fqdns": {"readonly": True}, + "direction": {"readonly": True}, + } + + _attribute_map = { + "protocol": {"key": "protocol", "type": "str"}, + "port": {"key": "port", "type": "int"}, + "ips": {"key": "ips", "type": "[str]"}, + "fqdns": {"key": "fqdns", "type": "[str]"}, + "direction": {"key": "direction", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.protocol = None + self.port = None + self.ips = None + self.fqdns = None + self.direction = None + + +class ResourceRequests(_serialization.Model): + """Deployment resource request payload. + + :ivar cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 for + Basic tier, and {500m, 1, 2, 3, 4} for Standard tier. + :vartype cpu: str + :ivar memory: Required memory. 1 GB can be represented by 1Gi or 1024Mi. This should be {512Mi, + 1Gi, 2Gi} for Basic tier, and {512Mi, 1Gi, 2Gi, ..., 8Gi} for Standard tier. + :vartype memory: str + """ + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + } + + def __init__(self, *, cpu: Optional[str] = None, memory: Optional[str] = None, **kwargs): + """ + :keyword cpu: Required CPU. 1 core can be represented by 1 or 1000m. This should be 500m or 1 + for Basic tier, and {500m, 1, 2, 3, 4} for Standard tier. + :paramtype cpu: str + :keyword memory: Required memory. 1 GB can be represented by 1Gi or 1024Mi. This should be + {512Mi, 1Gi, 2Gi} for Basic tier, and {512Mi, 1Gi, 2Gi, ..., 8Gi} for Standard tier. + :paramtype memory: str + """ + super().__init__(**kwargs) + self.cpu = cpu + self.memory = memory + + +class ResourceSku(_serialization.Model): + """Describes an available Azure Spring Apps SKU. + + :ivar resource_type: Gets the type of resource the SKU applies to. + :vartype resource_type: str + :ivar name: Gets the name of SKU. + :vartype name: str + :ivar tier: Gets the tier of SKU. + :vartype tier: str + :ivar capacity: Gets the capacity of SKU. + :vartype capacity: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SkuCapacity + :ivar locations: Gets the set of locations that the SKU is available. + :vartype locations: list[str] + :ivar location_info: Gets a list of locations and availability zones in those locations where + the SKU is available. + :vartype location_info: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSkuLocationInfo] + :ivar restrictions: Gets the restrictions because of which SKU cannot be used. This is + empty if there are no restrictions. + :vartype restrictions: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSkuRestrictions] + """ + + _attribute_map = { + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "SkuCapacity"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[ResourceSkuLocationInfo]"}, + "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, + } + + def __init__( + self, + *, + resource_type: Optional[str] = None, + name: Optional[str] = None, + tier: Optional[str] = None, + capacity: Optional["_models.SkuCapacity"] = None, + locations: Optional[List[str]] = None, + location_info: Optional[List["_models.ResourceSkuLocationInfo"]] = None, + restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None, + **kwargs + ): + """ + :keyword resource_type: Gets the type of resource the SKU applies to. + :paramtype resource_type: str + :keyword name: Gets the name of SKU. + :paramtype name: str + :keyword tier: Gets the tier of SKU. + :paramtype tier: str + :keyword capacity: Gets the capacity of SKU. + :paramtype capacity: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SkuCapacity + :keyword locations: Gets the set of locations that the SKU is available. + :paramtype locations: list[str] + :keyword location_info: Gets a list of locations and availability zones in those locations + where the SKU is available. + :paramtype location_info: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSkuLocationInfo] + :keyword restrictions: Gets the restrictions because of which SKU cannot be used. This is + empty if there are no restrictions. + :paramtype restrictions: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSkuRestrictions] + """ + super().__init__(**kwargs) + self.resource_type = resource_type + self.name = name + self.tier = tier + self.capacity = capacity + self.locations = locations + self.location_info = location_info + self.restrictions = restrictions + + +class ResourceSkuCapabilities(_serialization.Model): + """ResourceSkuCapabilities. + + :ivar name: Gets an invariant to describe the feature. + :vartype name: str + :ivar value: Gets an invariant if the feature is measured by quantity. + :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: Gets an invariant to describe the feature. + :paramtype name: str + :keyword value: Gets an invariant if the feature is measured by quantity. + :paramtype value: str + """ + super().__init__(**kwargs) + self.name = name + self.value = value + + +class ResourceSkuCollection(_serialization.Model): + """Object that includes an array of Azure Spring Apps SKU and a possible link for next set. + + :ivar value: Collection of resource SKU. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSku] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ResourceSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.ResourceSku"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of resource SKU. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSku] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ResourceSkuLocationInfo(_serialization.Model): + """Locations and availability zones where the SKU is available. + + :ivar location: Gets location of the SKU. + :vartype location: str + :ivar zones: Gets list of availability zones where the SKU is supported. + :vartype zones: list[str] + :ivar zone_details: Gets details of capabilities available to a SKU in specific zones. + :vartype zone_details: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSkuZoneDetails] + """ + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "zone_details": {"key": "zoneDetails", "type": "[ResourceSkuZoneDetails]"}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + zones: Optional[List[str]] = None, + zone_details: Optional[List["_models.ResourceSkuZoneDetails"]] = None, + **kwargs + ): + """ + :keyword location: Gets location of the SKU. + :paramtype location: str + :keyword zones: Gets list of availability zones where the SKU is supported. + :paramtype zones: list[str] + :keyword zone_details: Gets details of capabilities available to a SKU in specific zones. + :paramtype zone_details: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSkuZoneDetails] + """ + super().__init__(**kwargs) + self.location = location + self.zones = zones + self.zone_details = zone_details + + +class ResourceSkuRestrictionInfo(_serialization.Model): + """Information about the restriction where the SKU cannot be used. + + :ivar locations: Gets locations where the SKU is restricted. + :vartype locations: list[str] + :ivar zones: Gets list of availability zones where the SKU is restricted. + :vartype zones: list[str] + """ + + _attribute_map = { + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, + } + + def __init__(self, *, locations: Optional[List[str]] = None, zones: Optional[List[str]] = None, **kwargs): + """ + :keyword locations: Gets locations where the SKU is restricted. + :paramtype locations: list[str] + :keyword zones: Gets list of availability zones where the SKU is restricted. + :paramtype zones: list[str] + """ + super().__init__(**kwargs) + self.locations = locations + self.zones = zones + + +class ResourceSkuRestrictions(_serialization.Model): + """Restrictions where the SKU cannot be used. + + :ivar type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. Known + values are: "Location" and "Zone". + :vartype type: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSkuRestrictionsType + :ivar values: Gets the value of restrictions. If the restriction type is set to + location. This would be different locations where the SKU is restricted. + :vartype values: list[str] + :ivar restriction_info: Gets the information about the restriction where the SKU cannot be + used. + :vartype restriction_info: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSkuRestrictionInfo + :ivar reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". + :vartype reason_code: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSkuRestrictionsReasonCode + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "restriction_info": {"key": "restrictionInfo", "type": "ResourceSkuRestrictionInfo"}, + "reason_code": {"key": "reasonCode", "type": "str"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None, + values: Optional[List[str]] = None, + restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None, + reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None, + **kwargs + ): + """ + :keyword type: Gets the type of restrictions. Possible values include: 'Location', 'Zone'. + Known values are: "Location" and "Zone". + :paramtype type: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSkuRestrictionsType + :keyword values: Gets the value of restrictions. If the restriction type is set to + location. This would be different locations where the SKU is restricted. + :paramtype values: list[str] + :keyword restriction_info: Gets the information about the restriction where the SKU cannot be + used. + :paramtype restriction_info: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSkuRestrictionInfo + :keyword reason_code: Gets the reason for restriction. Possible values include: 'QuotaId', + 'NotAvailableForSubscription'. Known values are: "QuotaId" and "NotAvailableForSubscription". + :paramtype reason_code: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSkuRestrictionsReasonCode + """ + super().__init__(**kwargs) + self.type = type + self.values = values + self.restriction_info = restriction_info + self.reason_code = reason_code + + +class ResourceSkuZoneDetails(_serialization.Model): + """Details of capabilities available to a SKU in specific zones. + + :ivar name: Gets the set of zones that the SKU is available in with the + specified capabilities. + :vartype name: list[str] + :ivar capabilities: Gets a list of capabilities that are available for the SKU in the + specified list of zones. + :vartype capabilities: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSkuCapabilities] + """ + + _attribute_map = { + "name": {"key": "name", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, + } + + def __init__( + self, + *, + name: Optional[List[str]] = None, + capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None, + **kwargs + ): + """ + :keyword name: Gets the set of zones that the SKU is available in with the + specified capabilities. + :paramtype name: list[str] + :keyword capabilities: Gets a list of capabilities that are available for the SKU in the + specified list of zones. + :paramtype capabilities: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSkuCapabilities] + """ + super().__init__(**kwargs) + self.name = name + self.capabilities = capabilities + + +class ResourceUploadDefinition(_serialization.Model): + """Resource upload definition payload. + + :ivar relative_path: Source relative path. + :vartype relative_path: str + :ivar upload_url: Upload URL. + :vartype upload_url: str + """ + + _attribute_map = { + "relative_path": {"key": "relativePath", "type": "str"}, + "upload_url": {"key": "uploadUrl", "type": "str"}, + } + + def __init__(self, *, relative_path: Optional[str] = None, upload_url: Optional[str] = None, **kwargs): + """ + :keyword relative_path: Source relative path. + :paramtype relative_path: str + :keyword upload_url: Upload URL. + :paramtype upload_url: str + """ + super().__init__(**kwargs) + self.relative_path = relative_path + self.upload_url = upload_url + + +class ServiceRegistryInstance(_serialization.Model): + """Collection of instances belong to the Service Registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Service Registry instance. + :vartype name: str + :ivar status: Status of the Service Registry instance. + :vartype status: str + """ + + _validation = { + "name": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.status = None + + +class ServiceRegistryProperties(_serialization.Model): + """Service Registry properties payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of the Service Registry. Known values are: "Creating", + "Updating", "Succeeded", "Failed", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceRegistryProvisioningState + :ivar resource_requests: The requested resource quantity for required CPU and Memory. + :vartype resource_requests: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceRegistryResourceRequests + :ivar instances: Collection of instances belong to Service Registry. + :vartype instances: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceRegistryInstance] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "resource_requests": {"readonly": True}, + "instances": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_requests": {"key": "resourceRequests", "type": "ServiceRegistryResourceRequests"}, + "instances": {"key": "instances", "type": "[ServiceRegistryInstance]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.provisioning_state = None + self.resource_requests = None + self.instances = None + + +class ServiceRegistryResource(ProxyResource): + """Service Registry resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Service Registry properties payload. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceRegistryProperties + """ + + _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": "ServiceRegistryProperties"}, + } + + def __init__(self, *, properties: Optional["_models.ServiceRegistryProperties"] = None, **kwargs): + """ + :keyword properties: Service Registry properties payload. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceRegistryProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ServiceRegistryResourceCollection(_serialization.Model): + """Object that includes an array of Service Registry resources and a possible link for next set. + + :ivar value: Collection of Service Registry resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceRegistryResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ServiceRegistryResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ServiceRegistryResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of Service Registry resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceRegistryResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ServiceRegistryResourceRequests(_serialization.Model): + """Resource request payload of Service Registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cpu: Cpu allocated to each Service Registry instance. + :vartype cpu: str + :ivar memory: Memory allocated to each Service Registry instance. + :vartype memory: str + :ivar instance_count: Instance count of the Service Registry. + :vartype instance_count: int + """ + + _validation = { + "cpu": {"readonly": True}, + "memory": {"readonly": True}, + "instance_count": {"readonly": True}, + } + + _attribute_map = { + "cpu": {"key": "cpu", "type": "str"}, + "memory": {"key": "memory", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.cpu = None + self.memory = None + self.instance_count = None + + +class TrackedResource(Resource): + """The resource model definition for a ARM tracked top level resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar location: The GEO location of the resource. + :vartype location: str + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + """ + + _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"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword location: The GEO location of the resource. + :paramtype location: str + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.location = location + self.tags = tags + + +class ServiceResource(TrackedResource): + """Service resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar location: The GEO location of the resource. + :vartype location: str + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + :ivar properties: Properties of the Service resource. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ClusterResourceProperties + :ivar sku: Sku of the Service resource. + :vartype sku: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Sku + """ + + _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"}, + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "ClusterResourceProperties"}, + "sku": {"key": "sku", "type": "Sku"}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.ClusterResourceProperties"] = None, + sku: Optional["_models.Sku"] = None, + **kwargs + ): + """ + :keyword location: The GEO location of the resource. + :paramtype location: str + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. + :paramtype tags: dict[str, str] + :keyword properties: Properties of the Service resource. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ClusterResourceProperties + :keyword sku: Sku of the Service resource. + :paramtype sku: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Sku + """ + super().__init__(location=location, tags=tags, **kwargs) + self.properties = properties + self.sku = sku + + +class ServiceResourceList(_serialization.Model): + """Object that includes an array of Service resources and a possible link for next set. + + :ivar value: Collection of Service resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.ServiceResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: Collection of Service resources. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ServiceSpecification(_serialization.Model): + """Service specification payload. + + :ivar log_specifications: Specifications of the Log for Azure Monitoring. + :vartype log_specifications: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.LogSpecification] + :ivar metric_specifications: Specifications of the Metrics for Azure Monitoring. + :vartype metric_specifications: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.MetricSpecification] + """ + + _attribute_map = { + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, + } + + def __init__( + self, + *, + log_specifications: Optional[List["_models.LogSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, + **kwargs + ): + """ + :keyword log_specifications: Specifications of the Log for Azure Monitoring. + :paramtype log_specifications: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.LogSpecification] + :keyword metric_specifications: Specifications of the Metrics for Azure Monitoring. + :paramtype metric_specifications: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.MetricSpecification] + """ + super().__init__(**kwargs) + self.log_specifications = log_specifications + self.metric_specifications = metric_specifications + + +class ServiceVNetAddons(_serialization.Model): + """Additional Service settings in vnet injection instance. + + :ivar log_stream_public_endpoint: Indicates whether the log stream in vnet injection instance + could be accessed from internet. + :vartype log_stream_public_endpoint: bool + """ + + _attribute_map = { + "log_stream_public_endpoint": {"key": "logStreamPublicEndpoint", "type": "bool"}, + } + + def __init__(self, *, log_stream_public_endpoint: bool = False, **kwargs): + """ + :keyword log_stream_public_endpoint: Indicates whether the log stream in vnet injection + instance could be accessed from internet. + :paramtype log_stream_public_endpoint: bool + """ + super().__init__(**kwargs) + self.log_stream_public_endpoint = log_stream_public_endpoint + + +class Sku(_serialization.Model): + """Sku of Azure Spring Apps. + + :ivar name: Name of the Sku. + :vartype name: str + :ivar tier: Tier of the Sku. + :vartype tier: str + :ivar capacity: Current capacity of the target resource. + :vartype capacity: int + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, + } + + def __init__(self, *, name: str = "S0", tier: str = "Standard", capacity: Optional[int] = None, **kwargs): + """ + :keyword name: Name of the Sku. + :paramtype name: str + :keyword tier: Tier of the Sku. + :paramtype tier: str + :keyword capacity: Current capacity of the target resource. + :paramtype capacity: int + """ + super().__init__(**kwargs) + self.name = name + self.tier = tier + self.capacity = capacity + + +class SkuCapacity(_serialization.Model): + """The SKU capacity. + + All required parameters must be populated in order to send to Azure. + + :ivar minimum: Gets or sets the minimum. Required. + :vartype minimum: int + :ivar maximum: Gets or sets the maximum. + :vartype maximum: int + :ivar default: Gets or sets the default. + :vartype default: int + :ivar scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", and + "Automatic". + :vartype scale_type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.SkuScaleType + """ + + _validation = { + "minimum": {"required": True}, + } + + _attribute_map = { + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, + } + + def __init__( + self, + *, + minimum: int, + maximum: Optional[int] = None, + default: Optional[int] = None, + scale_type: Optional[Union[str, "_models.SkuScaleType"]] = None, + **kwargs + ): + """ + :keyword minimum: Gets or sets the minimum. Required. + :paramtype minimum: int + :keyword maximum: Gets or sets the maximum. + :paramtype maximum: int + :keyword default: Gets or sets the default. + :paramtype default: int + :keyword scale_type: Gets or sets the type of the scale. Known values are: "None", "Manual", + and "Automatic". + :paramtype scale_type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.SkuScaleType + """ + super().__init__(**kwargs) + self.minimum = minimum + self.maximum = maximum + self.default = default + self.scale_type = scale_type + + +class SourceUploadedUserSourceInfo(UploadedUserSourceInfo): + """Uploaded Java source code binary for a deployment. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the source uploaded. Required. + :vartype type: str + :ivar version: Version of the source. + :vartype version: str + :ivar relative_path: Relative path of the storage which stores the source. + :vartype relative_path: str + :ivar artifact_selector: Selector for the artifact to be used for the deployment for + multi-module projects. This should be + the relative path to the target module/project. + :vartype artifact_selector: str + :ivar runtime_version: Runtime version of the source file. + :vartype runtime_version: str + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "artifact_selector": {"key": "artifactSelector", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, + } + + def __init__( + self, + *, + version: Optional[str] = None, + relative_path: Optional[str] = None, + artifact_selector: Optional[str] = None, + runtime_version: Optional[str] = None, + **kwargs + ): + """ + :keyword version: Version of the source. + :paramtype version: str + :keyword relative_path: Relative path of the storage which stores the source. + :paramtype relative_path: str + :keyword artifact_selector: Selector for the artifact to be used for the deployment for + multi-module projects. This should be + the relative path to the target module/project. + :paramtype artifact_selector: str + :keyword runtime_version: Runtime version of the source file. + :paramtype runtime_version: str + """ + super().__init__(version=version, relative_path=relative_path, **kwargs) + self.type = "Source" # type: str + self.artifact_selector = artifact_selector + self.runtime_version = runtime_version + + +class SsoProperties(_serialization.Model): + """Single sign-on related configuration. + + :ivar scope: It defines the specific actions applications can be allowed to do on a user's + behalf. + :vartype scope: list[str] + :ivar client_id: The public identifier for the application. + :vartype client_id: str + :ivar client_secret: The secret known only to the application and the authorization server. + :vartype client_secret: str + :ivar issuer_uri: The URI of Issuer Identifier. + :vartype issuer_uri: str + """ + + _attribute_map = { + "scope": {"key": "scope", "type": "[str]"}, + "client_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, + "issuer_uri": {"key": "issuerUri", "type": "str"}, + } + + def __init__( + self, + *, + scope: Optional[List[str]] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + issuer_uri: Optional[str] = None, + **kwargs + ): + """ + :keyword scope: It defines the specific actions applications can be allowed to do on a user's + behalf. + :paramtype scope: list[str] + :keyword client_id: The public identifier for the application. + :paramtype client_id: str + :keyword client_secret: The secret known only to the application and the authorization server. + :paramtype client_secret: str + :keyword issuer_uri: The URI of Issuer Identifier. + :paramtype issuer_uri: str + """ + super().__init__(**kwargs) + self.scope = scope + self.client_id = client_id + self.client_secret = client_secret + self.issuer_uri = issuer_uri + + +class StackProperties(_serialization.Model): + """KPack ClusterStack properties payload. + + :ivar id: Id of the ClusterStack. + :vartype id: str + :ivar version: Version of the ClusterStack. + :vartype version: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__( + self, *, id: Optional[str] = None, version: Optional[str] = None, **kwargs # pylint: disable=redefined-builtin + ): + """ + :keyword id: Id of the ClusterStack. + :paramtype id: str + :keyword version: Version of the ClusterStack. + :paramtype version: str + """ + super().__init__(**kwargs) + self.id = id + self.version = version + + +class StorageProperties(_serialization.Model): + """Storage resource payload. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + StorageAccount + + All required parameters must be populated in order to send to Azure. + + :ivar storage_type: The type of the storage. Required. "StorageAccount" + :vartype storage_type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageType + """ + + _validation = { + "storage_type": {"required": True}, + } + + _attribute_map = { + "storage_type": {"key": "storageType", "type": "str"}, + } + + _subtype_map = {"storage_type": {"StorageAccount": "StorageAccount"}} + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.storage_type = None # type: Optional[str] + + +class StorageAccount(StorageProperties): + """storage resource of type Azure Storage Account. + + All required parameters must be populated in order to send to Azure. + + :ivar storage_type: The type of the storage. Required. "StorageAccount" + :vartype storage_type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageType + :ivar account_name: The account name of the Azure Storage Account. Required. + :vartype account_name: str + :ivar account_key: The account key of the Azure Storage Account. Required. + :vartype account_key: str + """ + + _validation = { + "storage_type": {"required": True}, + "account_name": {"required": True}, + "account_key": {"required": True}, + } + + _attribute_map = { + "storage_type": {"key": "storageType", "type": "str"}, + "account_name": {"key": "accountName", "type": "str"}, + "account_key": {"key": "accountKey", "type": "str"}, + } + + def __init__(self, *, account_name: str, account_key: str, **kwargs): + """ + :keyword account_name: The account name of the Azure Storage Account. Required. + :paramtype account_name: str + :keyword account_key: The account key of the Azure Storage Account. Required. + :paramtype account_key: str + """ + super().__init__(**kwargs) + self.storage_type = "StorageAccount" # type: str + self.account_name = account_name + self.account_key = account_key + + +class StorageResource(ProxyResource): + """Storage resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Properties of the storage resource payload. + :vartype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageProperties + """ + + _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": "StorageProperties"}, + } + + def __init__(self, *, properties: Optional["_models.StorageProperties"] = None, **kwargs): + """ + :keyword properties: Properties of the storage resource payload. + :paramtype properties: ~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class StorageResourceCollection(_serialization.Model): + """Collection compose of storage resources list and a possible link for next page. + + :ivar value: The storage resources list. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource] + :ivar next_link: The link to next page of storage list. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[StorageResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.StorageResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The storage resources list. + :paramtype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource] + :keyword next_link: The link to next page of storage list. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SupportedBuildpackResource(ProxyResource): + """Supported buildpack resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Supported buildpack resource properties. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedBuildpackResourceProperties + """ + + _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": "SupportedBuildpackResourceProperties"}, + } + + def __init__(self, *, properties: Optional["_models.SupportedBuildpackResourceProperties"] = None, **kwargs): + """ + :keyword properties: Supported buildpack resource properties. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedBuildpackResourceProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class SupportedBuildpackResourceProperties(_serialization.Model): + """Supported buildpack resource properties. + + :ivar buildpack_id: The id of supported buildpack. + :vartype buildpack_id: str + """ + + _attribute_map = { + "buildpack_id": {"key": "buildpackId", "type": "str"}, + } + + def __init__(self, *, buildpack_id: Optional[str] = None, **kwargs): + """ + :keyword buildpack_id: The id of supported buildpack. + :paramtype buildpack_id: str + """ + super().__init__(**kwargs) + self.buildpack_id = buildpack_id + + +class SupportedBuildpacksCollection(_serialization.Model): + """Object that includes an array of supported buildpacks resources and a possible link for next set. + + :ivar value: Collection of supported buildpacks resources. + :vartype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedBuildpackResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SupportedBuildpackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.SupportedBuildpackResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of supported buildpacks resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedBuildpackResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SupportedRuntimeVersion(_serialization.Model): + """Supported deployment runtime version descriptor. + + :ivar value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", "Java_17", and "NetCore_31". + :vartype value: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedRuntimeValue + :ivar platform: The platform of this runtime version (possible values: "Java" or ".NET"). Known + values are: "Java" and ".NET Core". + :vartype platform: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedRuntimePlatform + :ivar version: The detailed version (major.minor) of the platform. + :vartype version: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + "platform": {"key": "platform", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[Union[str, "_models.SupportedRuntimeValue"]] = None, + platform: Optional[Union[str, "_models.SupportedRuntimePlatform"]] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The raw value which could be passed to deployment CRUD operations. Known values + are: "Java_8", "Java_11", "Java_17", and "NetCore_31". + :paramtype value: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedRuntimeValue + :keyword platform: The platform of this runtime version (possible values: "Java" or ".NET"). + Known values are: "Java" and ".NET Core". + :paramtype platform: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedRuntimePlatform + :keyword version: The detailed version (major.minor) of the platform. + :paramtype version: str + """ + super().__init__(**kwargs) + self.value = value + self.platform = platform + self.version = version + + +class SupportedStackResource(ProxyResource): + """Supported stack resource payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SystemData + :ivar properties: Supported stack resource properties. + :vartype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedStackResourceProperties + """ + + _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": "SupportedStackResourceProperties"}, + } + + def __init__(self, *, properties: Optional["_models.SupportedStackResourceProperties"] = None, **kwargs): + """ + :keyword properties: Supported stack resource properties. + :paramtype properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedStackResourceProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class SupportedStackResourceProperties(_serialization.Model): + """Supported stack resource properties. + + :ivar stack_id: The id of supported stack. + :vartype stack_id: str + :ivar version: The version of supported stack. + :vartype version: str + """ + + _attribute_map = { + "stack_id": {"key": "stackId", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__(self, *, stack_id: Optional[str] = None, version: Optional[str] = None, **kwargs): + """ + :keyword stack_id: The id of supported stack. + :paramtype stack_id: str + :keyword version: The version of supported stack. + :paramtype version: str + """ + super().__init__(**kwargs) + self.stack_id = stack_id + self.version = version + + +class SupportedStacksCollection(_serialization.Model): + """Object that includes an array of supported stacks resources and a possible link for next set. + + :ivar value: Collection of supported stacks resources. + :vartype value: list[~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedStackResource] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SupportedStackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.SupportedStackResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Collection of supported stacks resources. + :paramtype value: + list[~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedStackResource] + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.LastModifiedByType + :ivar last_modified_at: The timestamp of resource modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.appplatform.v2022_11_01_preview.models.LastModifiedByType + :keyword last_modified_at: The timestamp of resource modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class TCPSocketAction(ProbeAction): + """TCPSocketAction describes an action based on opening a socket. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of the action to take to perform the health check. Required. Known values + are: "HTTPGetAction", "TCPSocketAction", and "ExecAction". + :vartype type: str or ~azure.mgmt.appplatform.v2022_11_01_preview.models.ProbeActionType + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type = "TCPSocketAction" # type: str + + +class TemporaryDisk(_serialization.Model): + """Temporary disk payload. + + :ivar size_in_gb: Size of the temporary disk in GB. + :vartype size_in_gb: int + :ivar mount_path: Mount path of the temporary disk. + :vartype mount_path: str + """ + + _validation = { + "size_in_gb": {"maximum": 5, "minimum": 0}, + } + + _attribute_map = { + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "mount_path": {"key": "mountPath", "type": "str"}, + } + + def __init__(self, *, size_in_gb: Optional[int] = None, mount_path: str = "/tmp", **kwargs): + """ + :keyword size_in_gb: Size of the temporary disk in GB. + :paramtype size_in_gb: int + :keyword mount_path: Mount path of the temporary disk. + :paramtype mount_path: str + """ + super().__init__(**kwargs) + self.size_in_gb = size_in_gb + self.mount_path = mount_path + + +class TestKeys(_serialization.Model): + """Test keys payload. + + :ivar primary_key: Primary key. + :vartype primary_key: str + :ivar secondary_key: Secondary key. + :vartype secondary_key: str + :ivar primary_test_endpoint: Primary test endpoint. + :vartype primary_test_endpoint: str + :ivar secondary_test_endpoint: Secondary test endpoint. + :vartype secondary_test_endpoint: str + :ivar enabled: Indicates whether the test endpoint feature enabled or not. + :vartype enabled: bool + """ + + _attribute_map = { + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "primary_test_endpoint": {"key": "primaryTestEndpoint", "type": "str"}, + "secondary_test_endpoint": {"key": "secondaryTestEndpoint", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + } + + def __init__( + self, + *, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + primary_test_endpoint: Optional[str] = None, + secondary_test_endpoint: Optional[str] = None, + enabled: Optional[bool] = None, + **kwargs + ): + """ + :keyword primary_key: Primary key. + :paramtype primary_key: str + :keyword secondary_key: Secondary key. + :paramtype secondary_key: str + :keyword primary_test_endpoint: Primary test endpoint. + :paramtype primary_test_endpoint: str + :keyword secondary_test_endpoint: Secondary test endpoint. + :paramtype secondary_test_endpoint: str + :keyword enabled: Indicates whether the test endpoint feature enabled or not. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.primary_key = primary_key + self.secondary_key = secondary_key + self.primary_test_endpoint = primary_test_endpoint + self.secondary_test_endpoint = secondary_test_endpoint + self.enabled = enabled + + +class TriggeredBuildResult(_serialization.Model): + """The build result triggered by a build. + + :ivar id: The unique build id of this build result. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: The unique build id of this build result. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class UserAssignedManagedIdentity(_serialization.Model): + """The details of the user-assigned managed identity assigned to an App. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: Principal Id of user-assigned managed identity. + :vartype principal_id: str + :ivar client_id: Client Id of user-assigned managed identity. + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class ValidationMessages(_serialization.Model): + """Validate messages of the configuration service git repositories. + + :ivar name: The name of the configuration service git repository. + :vartype name: str + :ivar messages: Detailed validation messages. + :vartype messages: list[str] + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "messages": {"key": "messages", "type": "[str]"}, + } + + def __init__(self, *, name: Optional[str] = None, messages: Optional[List[str]] = None, **kwargs): + """ + :keyword name: The name of the configuration service git repository. + :paramtype name: str + :keyword messages: Detailed validation messages. + :paramtype messages: list[str] + """ + super().__init__(**kwargs) + self.name = name + self.messages = messages diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/models/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/__init__.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/__init__.py new file mode 100644 index 000000000000..34185c849b5b --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/__init__.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._services_operations import ServicesOperations +from ._config_servers_operations import ConfigServersOperations +from ._configuration_services_operations import ConfigurationServicesOperations +from ._service_registries_operations import ServiceRegistriesOperations +from ._application_live_views_operations import ApplicationLiveViewsOperations +from ._dev_tool_portals_operations import DevToolPortalsOperations +from ._build_service_operations import BuildServiceOperations +from ._buildpack_binding_operations import BuildpackBindingOperations +from ._build_service_builder_operations import BuildServiceBuilderOperations +from ._build_service_agent_pool_operations import BuildServiceAgentPoolOperations +from ._monitoring_settings_operations import MonitoringSettingsOperations +from ._apps_operations import AppsOperations +from ._bindings_operations import BindingsOperations +from ._storages_operations import StoragesOperations +from ._certificates_operations import CertificatesOperations +from ._custom_domains_operations import CustomDomainsOperations +from ._deployments_operations import DeploymentsOperations +from ._operations import Operations +from ._runtime_versions_operations import RuntimeVersionsOperations +from ._skus_operations import SkusOperations +from ._gateways_operations import GatewaysOperations +from ._gateway_route_configs_operations import GatewayRouteConfigsOperations +from ._gateway_custom_domains_operations import GatewayCustomDomainsOperations +from ._api_portals_operations import ApiPortalsOperations +from ._api_portal_custom_domains_operations import ApiPortalCustomDomainsOperations +from ._application_accelerators_operations import ApplicationAcceleratorsOperations +from ._customized_accelerators_operations import CustomizedAcceleratorsOperations +from ._predefined_accelerators_operations import PredefinedAcceleratorsOperations + +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__ = [ + "ServicesOperations", + "ConfigServersOperations", + "ConfigurationServicesOperations", + "ServiceRegistriesOperations", + "ApplicationLiveViewsOperations", + "DevToolPortalsOperations", + "BuildServiceOperations", + "BuildpackBindingOperations", + "BuildServiceBuilderOperations", + "BuildServiceAgentPoolOperations", + "MonitoringSettingsOperations", + "AppsOperations", + "BindingsOperations", + "StoragesOperations", + "CertificatesOperations", + "CustomDomainsOperations", + "DeploymentsOperations", + "Operations", + "RuntimeVersionsOperations", + "SkusOperations", + "GatewaysOperations", + "GatewayRouteConfigsOperations", + "GatewayCustomDomainsOperations", + "ApiPortalsOperations", + "ApiPortalCustomDomainsOperations", + "ApplicationAcceleratorsOperations", + "CustomizedAcceleratorsOperations", + "PredefinedAcceleratorsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_api_portal_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_api_portal_custom_domains_operations.py new file mode 100644 index 000000000000..646a6eee537a --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_api_portal_custom_domains_operations.py @@ -0,0 +1,759 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, + service_name: str, + api_portal_name: str, + domain_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, + service_name: str, + api_portal_name: str, + domain_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( + resource_group_name: str, service_name: str, api_portal_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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 ApiPortalCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`api_portal_custom_domains` 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, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any + ) -> _models.ApiPortalCustomDomainResource: + """Get the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiPortalCustomDomainResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], + **kwargs: Any + ) -> _models.ApiPortalCustomDomainResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_custom_domain_resource, (IO, bytes)): + _content = api_portal_custom_domain_resource + else: + _json = self._serialize.body(api_portal_custom_domain_resource, "ApiPortalCustomDomainResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApiPortalCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: _models.ApiPortalCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Required. + :type api_portal_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + domain_name: str, + api_portal_custom_domain_resource: Union[_models.ApiPortalCustomDomainResource, IO], + **kwargs: Any + ) -> LROPoller[_models.ApiPortalCustomDomainResource]: + """Create or update the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_name: str + :param api_portal_custom_domain_resource: The API portal custom domain for the create or update + operation. Is either a model type or a IO type. Required. + :type api_portal_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalCustomDomainResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResource] + 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, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_name, + api_portal_custom_domain_resource=api_portal_custom_domain_resource, + 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("ApiPortalCustomDomainResource", 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, domain_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the API portal custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param domain_name: The name of the API portal custom domain. Required. + :type domain_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + api_portal_name=api_portal_name, + domain_name=domain_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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> Iterable["_models.ApiPortalCustomDomainResource"]: + """Handle requests to list all API portal custom domains. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiPortalCustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalCustomDomainResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalCustomDomainResourceCollection] + + 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, + service_name=service_name, + api_portal_name=api_portal_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiPortalCustomDomainResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_api_portals_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_api_portals_operations.py new file mode 100644 index 000000000000..aeaee0d27b14 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_api_portals_operations.py @@ -0,0 +1,900 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_name: str, api_portal_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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, service_name: str, api_portal_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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, service_name: str, api_portal_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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_request(resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_domain_request( + resource_group_name: str, service_name: str, api_portal_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiPortalName": _SERIALIZER.url("api_portal_name", api_portal_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 ApiPortalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`api_portals` 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, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> _models.ApiPortalResource: + """Get the API portal and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiPortalResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiPortalResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: Union[_models.ApiPortalResource, IO], + **kwargs: Any + ) -> _models.ApiPortalResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_portal_resource, (IO, bytes)): + _content = api_portal_resource + else: + _json = self._serialize.body(api_portal_resource, "ApiPortalResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApiPortalResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApiPortalResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: _models.ApiPortalResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Required. + :type api_portal_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + api_portal_resource: Union[_models.ApiPortalResource, IO], + **kwargs: Any + ) -> LROPoller[_models.ApiPortalResource]: + """Create the default API portal or update the existing API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param api_portal_resource: The API portal for the create or update operation. Is either a + model type or a IO type. Required. + :type api_portal_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApiPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResource] + 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, + service_name=service_name, + api_portal_name=api_portal_name, + api_portal_resource=api_portal_resource, + 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("ApiPortalResource", 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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, api_portal_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, api_portal_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the default API portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + api_portal_name=api_portal_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.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.ApiPortalResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiPortalResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApiPortalResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiPortalResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiPortalResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals"} # type: ignore + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + api_portal_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param api_portal_name: The name of API portal. Required. + :type api_portal_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") + + request = build_validate_domain_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_portal_name=api_portal_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate_domain.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apiPortals/{apiPortalName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_application_accelerators_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_application_accelerators_operations.py new file mode 100644 index 000000000000..ae9d81ea92d9 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_application_accelerators_operations.py @@ -0,0 +1,722 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_name: str, application_accelerator_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationAcceleratorName": _SERIALIZER.url( + "application_accelerator_name", application_accelerator_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, service_name: str, application_accelerator_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationAcceleratorName": _SERIALIZER.url( + "application_accelerator_name", application_accelerator_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, service_name: str, application_accelerator_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationAcceleratorName": _SERIALIZER.url( + "application_accelerator_name", application_accelerator_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 ApplicationAcceleratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`application_accelerators` 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, service_name: str, **kwargs: Any + ) -> Iterable["_models.ApplicationAcceleratorResource"]: + """Handle requests to list all application accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationAcceleratorResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationAcceleratorResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationAcceleratorResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, application_accelerator_name: str, **kwargs: Any + ) -> _models.ApplicationAcceleratorResource: + """Get the application accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationAcceleratorResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationAcceleratorResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationAcceleratorResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + application_accelerator_resource: Union[_models.ApplicationAcceleratorResource, IO], + **kwargs: Any + ) -> _models.ApplicationAcceleratorResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationAcceleratorResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application_accelerator_resource, (IO, bytes)): + _content = application_accelerator_resource + else: + _json = self._serialize.body(application_accelerator_resource, "ApplicationAcceleratorResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApplicationAcceleratorResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApplicationAcceleratorResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + application_accelerator_resource: _models.ApplicationAcceleratorResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApplicationAcceleratorResource]: + """Create or update the application accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param application_accelerator_resource: The application accelerator for the create or update + operation. Required. + :type application_accelerator_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationAcceleratorResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + application_accelerator_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApplicationAcceleratorResource]: + """Create or update the application accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param application_accelerator_resource: The application accelerator for the create or update + operation. Required. + :type application_accelerator_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationAcceleratorResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + application_accelerator_resource: Union[_models.ApplicationAcceleratorResource, IO], + **kwargs: Any + ) -> LROPoller[_models.ApplicationAcceleratorResource]: + """Create or update the application accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param application_accelerator_resource: The application accelerator for the create or update + operation. Is either a model type or a IO type. Required. + :type application_accelerator_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationAcceleratorResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationAcceleratorResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationAcceleratorResource] + 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, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + application_accelerator_resource=application_accelerator_resource, + 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("ApplicationAcceleratorResource", 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.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, application_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, application_accelerator_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the application accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + application_accelerator_name=application_accelerator_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.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_application_live_views_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_application_live_views_operations.py new file mode 100644 index 000000000000..0019b9afdfb7 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_application_live_views_operations.py @@ -0,0 +1,714 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationLiveViews", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_name: str, application_live_view_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationLiveViews/{applicationLiveViewName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationLiveViewName": _SERIALIZER.url("application_live_view_name", application_live_view_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, service_name: str, application_live_view_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/applicationLiveViews/{applicationLiveViewName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationLiveViewName": _SERIALIZER.url("application_live_view_name", application_live_view_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, service_name: str, application_live_view_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationLiveViews/{applicationLiveViewName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationLiveViewName": _SERIALIZER.url("application_live_view_name", application_live_view_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 ApplicationLiveViewsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`application_live_views` 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, service_name: str, **kwargs: Any + ) -> Iterable["_models.ApplicationLiveViewResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationLiveViewResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationLiveViewResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationLiveViewResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationLiveViews"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, application_live_view_name: str, **kwargs: Any + ) -> _models.ApplicationLiveViewResource: + """Get the Application Live and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_live_view_name: The name of Application Live View. Required. + :type application_live_view_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationLiveViewResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationLiveViewResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_live_view_name=application_live_view_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationLiveViewResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationLiveViews/{applicationLiveViewName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + application_live_view_name: str, + application_live_view_resource: Union[_models.ApplicationLiveViewResource, IO], + **kwargs: Any + ) -> _models.ApplicationLiveViewResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationLiveViewResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application_live_view_resource, (IO, bytes)): + _content = application_live_view_resource + else: + _json = self._serialize.body(application_live_view_resource, "ApplicationLiveViewResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_live_view_name=application_live_view_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApplicationLiveViewResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApplicationLiveViewResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationLiveViews/{applicationLiveViewName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_live_view_name: str, + application_live_view_resource: _models.ApplicationLiveViewResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApplicationLiveViewResource]: + """Create the default Application Live View or update the existing Application Live View. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_live_view_name: The name of Application Live View. Required. + :type application_live_view_name: str + :param application_live_view_resource: Parameters for the update operation. Required. + :type application_live_view_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationLiveViewResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_live_view_name: str, + application_live_view_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApplicationLiveViewResource]: + """Create the default Application Live View or update the existing Application Live View. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_live_view_name: The name of Application Live View. Required. + :type application_live_view_name: str + :param application_live_view_resource: Parameters for the update operation. Required. + :type application_live_view_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationLiveViewResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_live_view_name: str, + application_live_view_resource: Union[_models.ApplicationLiveViewResource, IO], + **kwargs: Any + ) -> LROPoller[_models.ApplicationLiveViewResource]: + """Create the default Application Live View or update the existing Application Live View. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_live_view_name: The name of Application Live View. Required. + :type application_live_view_name: str + :param application_live_view_resource: Parameters for the update operation. Is either a model + type or a IO type. Required. + :type application_live_view_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationLiveViewResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ApplicationLiveViewResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationLiveViewResource] + 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, + service_name=service_name, + application_live_view_name=application_live_view_name, + application_live_view_resource=application_live_view_resource, + 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("ApplicationLiveViewResource", 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.AppPlatform/Spring/{serviceName}/applicationLiveViews/{applicationLiveViewName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, application_live_view_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_live_view_name=application_live_view_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationLiveViews/{applicationLiveViewName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, application_live_view_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Disable the default Application Live View. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_live_view_name: The name of Application Live View. Required. + :type application_live_view_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + application_live_view_name=application_live_view_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.AppPlatform/Spring/{serviceName}/applicationLiveViews/{applicationLiveViewName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_apps_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_apps_operations.py new file mode 100644 index 000000000000..21cd5e5e3df6 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_apps_operations.py @@ -0,0 +1,1572 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + app_name: str, + subscription_id: str, + *, + sync_status: 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if sync_status is not None: + _params["syncStatus"] = _SERIALIZER.query("sync_status", sync_status, "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, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 + 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, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_resource_upload_url_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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_set_active_deployments_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_domain_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 + 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 AppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`apps` 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, + resource_group_name: str, + service_name: str, + app_name: str, + sync_status: Optional[str] = None, + **kwargs: Any + ) -> _models.AppResource: + """Get an App and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param sync_status: Indicates whether sync status. Default value is None. + :type sync_status: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AppResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + sync_status=sync_status, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> _models.AppResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Create a new App or update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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, + service_name=service_name, + app_name=app_name, + app_resource=app_resource, + 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("AppResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Operation to delete an App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + app_name=app_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.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> _models.AppResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(app_resource, (IO, bytes)): + _content = app_resource + else: + _json = self._serialize.body(app_resource, "AppResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: _models.AppResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Required. + :type app_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + app_resource: Union[_models.AppResource, IO], + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Operation to update an exiting App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param app_resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type app_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + app_resource=app_resource, + 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("AppResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.AppResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AppResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AppResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps"} # type: ignore + + @distributed_trace + def get_resource_upload_url( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: + """Get an resource upload URL for an App, which may be artifacts or source archive. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceUploadDefinition or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceUploadDefinition + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] + + request = build_get_resource_upload_url_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_resource_upload_url.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl"} # type: ignore + + def _set_active_deployments_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], + **kwargs: Any + ) -> _models.AppResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(active_deployment_collection, (IO, bytes)): + _content = active_deployment_collection + else: + _json = self._serialize.body(active_deployment_collection, "ActiveDeploymentCollection") + + request = build_set_active_deployments_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._set_active_deployments_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AppResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AppResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _set_active_deployments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + + @overload + def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: _models.ActiveDeploymentCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ActiveDeploymentCollection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Required. + :type active_deployment_collection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_set_active_deployments( + self, + resource_group_name: str, + service_name: str, + app_name: str, + active_deployment_collection: Union[_models.ActiveDeploymentCollection, IO], + **kwargs: Any + ) -> LROPoller[_models.AppResource]: + """Set existing Deployment under the app as active. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param active_deployment_collection: A list of Deployment name to be active. Is either a model + type or a IO type. Required. + :type active_deployment_collection: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ActiveDeploymentCollection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AppResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.AppResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AppResource] + 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._set_active_deployments_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + active_deployment_collection=active_deployment_collection, + 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("AppResource", 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_set_active_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/setActiveDeployments"} # type: ignore + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + app_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the resource name is valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") + + request = build_validate_domain_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate_domain.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_bindings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_bindings_operations.py new file mode 100644 index 000000000000..8c9b94f0b388 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_bindings_operations.py @@ -0,0 +1,1033 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_name: str, app_name: str, binding_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, service_name: str, app_name: str, binding_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, service_name: str, app_name: str, binding_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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, service_name: str, app_name: str, binding_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "bindingName": _SERIALIZER.url("binding_name", binding_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) + + +def build_list_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 BindingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`bindings` 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, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> _models.BindingResource: + """Get a Binding and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BindingResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> _models.BindingResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Create a new Binding or update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + 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, + service_name=service_name, + app_name=app_name, + binding_name=binding_name, + binding_resource=binding_resource, + 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("BindingResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, binding_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, binding_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Operation to delete a Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + app_name=app_name, + binding_name=binding_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.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> _models.BindingResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(binding_resource, (IO, bytes)): + _content = binding_resource + else: + _json = self._serialize.body(binding_resource, "BindingResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("BindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: _models.BindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Required. + :type binding_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + binding_name: str, + binding_resource: Union[_models.BindingResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BindingResource]: + """Operation to update an exiting Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param binding_name: The name of the Binding resource. Required. + :type binding_name: str + :param binding_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type binding_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + binding_name=binding_name, + binding_resource=binding_resource, + 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("BindingResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings/{bindingName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.BindingResource"]: + """Handles requests to list all resources in an App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type 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 BindingResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.BindingResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BindingResourceCollection] + + 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, + service_name=service_name, + app_name=app_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BindingResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/bindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_build_service_agent_pool_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_build_service_agent_pool_operations.py new file mode 100644 index 000000000000..f1b86b552015 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_build_service_agent_pool_operations.py @@ -0,0 +1,597 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, service_name: str, build_service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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, + service_name: str, + build_service_name: str, + agent_pool_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_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_update_put_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_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) + + +class BuildServiceAgentPoolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`build_service_agent_pool` 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, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.BuildServiceAgentPoolResource"]: + """List build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildServiceAgentPoolResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResourceCollection] + + 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, + service_name=service_name, + build_service_name=build_service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BuildServiceAgentPoolResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, build_service_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: + """Get build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildServiceAgentPoolResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + agent_pool_name=agent_pool_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + + def _update_put_initial( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], + **kwargs: Any + ) -> _models.BuildServiceAgentPoolResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(agent_pool_resource, (IO, bytes)): + _content = agent_pool_resource + else: + _json = self._serialize.body(agent_pool_resource, "BuildServiceAgentPoolResource") + + request = build_update_put_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_put_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BuildServiceAgentPoolResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: _models.BuildServiceAgentPoolResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Required. + :type agent_pool_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + agent_pool_name: str, + agent_pool_resource: Union[_models.BuildServiceAgentPoolResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BuildServiceAgentPoolResource]: + """Create or update build service agent pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param agent_pool_name: The name of the build service agent pool resource. Required. + :type agent_pool_name: str + :param agent_pool_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type agent_pool_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildServiceAgentPoolResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildServiceAgentPoolResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceAgentPoolResource] + 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_put_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + agent_pool_name=agent_pool_name, + agent_pool_resource=agent_pool_resource, + 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("BuildServiceAgentPoolResource", 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_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/agentPools/{agentPoolName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_build_service_builder_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_build_service_builder_operations.py new file mode 100644 index 000000000000..1faa51c17c36 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_build_service_builder_operations.py @@ -0,0 +1,864 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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, + service_name: str, + build_service_name: str, + builder_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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, + service_name: str, + build_service_name: str, + builder_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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_request( + resource_group_name: str, service_name: str, build_service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_deployments_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/listUsingDeployments", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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 BuildServiceBuilderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`build_service_builder` 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, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.BuilderResource: + """Get a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuilderResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuilderResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: Union[_models.BuilderResource, IO], + **kwargs: Any + ) -> _models.BuilderResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(builder_resource, (IO, bytes)): + _content = builder_resource + else: + _json = self._serialize.body(builder_resource, "BuilderResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BuilderResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BuilderResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: _models.BuilderResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Required. + :type builder_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + builder_resource: Union[_models.BuilderResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BuilderResource]: + """Create or update a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param builder_resource: The target builder for the create or update operation. Is either a + model type or a IO type. Required. + :type builder_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuilderResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResource] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + builder_resource=builder_resource, + 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("BuilderResource", 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, build_service_name: str, builder_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a KPack builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.BuilderResource"]: + """List KPack builders result. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuilderResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuilderResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuilderResourceCollection] + + 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, + service_name=service_name, + build_service_name=build_service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BuilderResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders"} # type: ignore + + @distributed_trace + def list_deployments( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> _models.DeploymentList: + """List deployments that are using the builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentList or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentList + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentList] + + request = build_list_deployments_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_deployments.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeploymentList", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_deployments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/listUsingDeployments"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_build_service_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_build_service_operations.py new file mode 100644 index 000000000000..3548ad5b68d2 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_build_service_operations.py @@ -0,0 +1,1624 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_build_services_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_build_service_request( + resource_group_name: str, service_name: str, build_service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_builds_request( + resource_group_name: str, service_name: str, build_service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_build_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_build_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_list_build_results_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_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_build_result_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build_result_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_name, "str"), + "buildResultName": _SERIALIZER.url("build_result_name", build_result_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_build_result_log_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build_result_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildName": _SERIALIZER.url("build_name", build_name, "str"), + "buildResultName": _SERIALIZER.url("build_result_name", build_result_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_resource_upload_url_request( + resource_group_name: str, service_name: str, build_service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_list_supported_buildpacks_request( + resource_group_name: str, service_name: str, build_service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_supported_buildpack_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + buildpack_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "buildpackName": _SERIALIZER.url("buildpack_name", buildpack_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_supported_stacks_request( + resource_group_name: str, service_name: str, build_service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_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_supported_stack_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + stack_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "stackName": _SERIALIZER.url("stack_name", stack_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 BuildServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`build_service` 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_build_services( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.BuildService"]: + """List build services resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildService or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildService] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildServiceCollection] + + 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_build_services_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_build_services.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BuildServiceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_build_services.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices"} # type: ignore + + @distributed_trace + def get_build_service( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.BuildService: + """Get a build service resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildService or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildService + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildService] + + request = build_get_build_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build_service.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildService", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}"} # type: ignore + + @distributed_trace + def list_builds( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> Iterable["_models.Build"]: + """List KPack builds. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Build or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.Build] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildCollection] + + 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_builds_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_builds.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BuildCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_builds.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds"} # type: ignore + + @distributed_trace + def get_build( + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> _models.Build: + """Get a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Build + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] + + request = build_get_build_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Build", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + + @overload + def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: _models.Build, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Build + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Required. + :type build: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Build + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_build( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build: Union[_models.Build, IO], + **kwargs: Any + ) -> _models.Build: + """Create or update a KPack build. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type build: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Build or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Build or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.Build + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Build] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build, (IO, bytes)): + _content = build + else: + _json = self._serialize.body(build, "Build") + + request = build_create_or_update_build_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_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_build.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Build", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Build", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_build.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}"} # type: ignore + + @distributed_trace + def list_build_results( + self, resource_group_name: str, service_name: str, build_service_name: str, build_name: str, **kwargs: Any + ) -> Iterable["_models.BuildResult"]: + """List KPack build results. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildResult] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultCollection] + + 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_build_results_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_build_results.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BuildResultCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_build_results.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results"} # type: ignore + + @distributed_trace + def get_build_result( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build_result_name: str, + **kwargs: Any + ) -> _models.BuildResult: + """Get a KPack build result. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build_result_name: The name of the build result resource. Required. + :type build_result_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildResult + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResult] + + request = build_get_build_result_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + build_result_name=build_result_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build_result.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}"} # type: ignore + + @distributed_trace + def get_build_result_log( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + build_name: str, + build_result_name: str, + **kwargs: Any + ) -> _models.BuildResultLog: + """Get a KPack build result log download URL. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param build_name: The name of the build resource. Required. + :type build_name: str + :param build_result_name: The name of the build result resource. Required. + :type build_result_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildResultLog or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildResultLog + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildResultLog] + + request = build_get_build_result_log_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + build_name=build_name, + build_result_name=build_result_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_build_result_log.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildResultLog", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_build_result_log.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}/getLogFileUrl"} # type: ignore + + @distributed_trace + def get_resource_upload_url( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.ResourceUploadDefinition: + """Get an resource upload URL for build service, which may be artifacts or source archive. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceUploadDefinition or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceUploadDefinition + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUploadDefinition] + + request = build_get_resource_upload_url_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_resource_upload_url.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceUploadDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_resource_upload_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/getResourceUploadUrl"} # type: ignore + + @distributed_trace + def list_supported_buildpacks( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedBuildpacksCollection: + """Get all supported buildpacks. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedBuildpacksCollection or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedBuildpacksCollection + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpacksCollection] + + request = build_list_supported_buildpacks_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_supported_buildpacks.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedBuildpacksCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_supported_buildpacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks"} # type: ignore + + @distributed_trace + def get_supported_buildpack( + self, resource_group_name: str, service_name: str, build_service_name: str, buildpack_name: str, **kwargs: Any + ) -> _models.SupportedBuildpackResource: + """Get the supported buildpack resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param buildpack_name: The name of the buildpack resource. Required. + :type buildpack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedBuildpackResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedBuildpackResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedBuildpackResource] + + request = build_get_supported_buildpack_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + buildpack_name=buildpack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_supported_buildpack.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedBuildpackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_supported_buildpack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}"} # type: ignore + + @distributed_trace + def list_supported_stacks( + self, resource_group_name: str, service_name: str, build_service_name: str, **kwargs: Any + ) -> _models.SupportedStacksCollection: + """Get all supported stacks. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedStacksCollection or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedStacksCollection + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStacksCollection] + + request = build_list_supported_stacks_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_supported_stacks.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedStacksCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_supported_stacks.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks"} # type: ignore + + @distributed_trace + def get_supported_stack( + self, resource_group_name: str, service_name: str, build_service_name: str, stack_name: str, **kwargs: Any + ) -> _models.SupportedStackResource: + """Get the supported stack resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param stack_name: The name of the stack resource. Required. + :type stack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportedStackResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.SupportedStackResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SupportedStackResource] + + request = build_get_supported_stack_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + stack_name=stack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_supported_stack.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportedStackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_supported_stack.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedStacks/{stackName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_buildpack_binding_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_buildpack_binding_operations.py new file mode 100644 index 000000000000..732d6639914d --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_buildpack_binding_operations.py @@ -0,0 +1,811 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_name, "str"), + "buildpackBindingName": _SERIALIZER.url("buildpack_binding_name", buildpack_binding_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_request( + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "buildServiceName": _SERIALIZER.url("build_service_name", build_service_name, "str"), + "builderName": _SERIALIZER.url("builder_name", builder_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 BuildpackBindingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`buildpack_binding` 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, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + **kwargs: Any + ) -> _models.BuildpackBindingResource: + """Get a buildpack binding by name. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BuildpackBindingResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> _models.BuildpackBindingResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(buildpack_binding, (IO, bytes)): + _content = buildpack_binding + else: + _json = self._serialize.body(buildpack_binding, "BuildpackBindingResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BuildpackBindingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: _models.BuildpackBindingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. + Required. + :type buildpack_binding: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + buildpack_binding: Union[_models.BuildpackBindingResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BuildpackBindingResource]: + """Create or update a buildpack binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_name: str + :param buildpack_binding: The target buildpack binding for the create or update operation. Is + either a model type or a IO type. Required. + :type buildpack_binding: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResource] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_name, + buildpack_binding=buildpack_binding, + 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("BuildpackBindingResource", 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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + service_name: str, + build_service_name: str, + builder_name: str, + buildpack_binding_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Operation to delete a Buildpack Binding. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :param buildpack_binding_name: The name of the Buildpack Binding Name. Required. + :type buildpack_binding_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_name, + buildpack_binding_name=buildpack_binding_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.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings/{buildpackBindingName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, build_service_name: str, builder_name: str, **kwargs: Any + ) -> Iterable["_models.BuildpackBindingResource"]: + """Handles requests to list all buildpack bindings in a builder. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param build_service_name: The name of the build service resource. Required. + :type build_service_name: str + :param builder_name: The name of the builder resource. Required. + :type builder_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BuildpackBindingResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.BuildpackBindingResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BuildpackBindingResourceCollection] + + 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, + service_name=service_name, + build_service_name=build_service_name, + builder_name=builder_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BuildpackBindingResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builders/{builderName}/buildpackBindings"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_certificates_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_certificates_operations.py new file mode 100644 index 000000000000..6658d3403cf3 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_certificates_operations.py @@ -0,0 +1,716 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_list_request(resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`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 get( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateResource: + """Get the certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: Union[_models.CertificateResource, IO], + **kwargs: Any + ) -> _models.CertificateResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_resource, (IO, bytes)): + _content = certificate_resource + else: + _json = self._serialize.body(certificate_resource, "CertificateResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_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_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("CertificateResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: _models.CertificateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Required. + :type certificate_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_name: str, + certificate_resource: Union[_models.CertificateResource, IO], + **kwargs: Any + ) -> LROPoller[_models.CertificateResource]: + """Create or update certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_name: str + :param certificate_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type certificate_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CertificateResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResource] + 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, + service_name=service_name, + certificate_name=certificate_name, + certificate_resource=certificate_resource, + 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("CertificateResource", 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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, certificate_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + certificate_name=certificate_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, certificate_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the certificate resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param certificate_name: The name of the certificate resource. Required. + :type certificate_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + certificate_name=certificate_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.AppPlatform/Spring/{serviceName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.CertificateResource"]: + """List all the certificates of one user. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CertificateResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.CertificateResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CertificateResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/certificates"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_config_servers_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_config_servers_operations.py new file mode 100644 index 000000000000..58cce6c7fbf4 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_config_servers_operations.py @@ -0,0 +1,950 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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) + + +def build_validate_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configServers/validate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ConfigServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`config_servers` 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, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ConfigServerResource: + """Get the config server and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigServerResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + def _update_put_initial( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> _models.ConfigServerResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_put_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_put_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_put_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + config_server_resource=config_server_resource, + 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("ConfigServerResource", 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_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + def _update_patch_initial( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> _models.ConfigServerResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_resource, (IO, bytes)): + _content = config_server_resource + else: + _json = self._serialize.body(config_server_resource, "ConfigServerResource") + + request = build_update_patch_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_patch_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigServerResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: _models.ConfigServerResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Required. + :type config_server_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + config_server_resource: Union[_models.ConfigServerResource, IO], + **kwargs: Any + ) -> LROPoller[_models.ConfigServerResource]: + """Update the config server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_resource: Parameters for the update operation. Is either a model type or a + IO type. Required. + :type config_server_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerResource] + 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_patch_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + config_server_resource=config_server_resource, + 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("ConfigServerResource", 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_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/default"} # type: ignore + + def _validate_initial( + self, + resource_group_name: str, + service_name: str, + config_server_settings: Union[_models.ConfigServerSettings, IO], + **kwargs: Any + ) -> _models.ConfigServerSettingsValidateResult: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_server_settings, (IO, bytes)): + _content = config_server_settings + else: + _json = self._serialize.body(config_server_settings, "ConfigServerSettings") + + request = build_validate_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._validate_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigServerSettingsValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: _models.ConfigServerSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Required. + :type config_server_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate( + self, + resource_group_name: str, + service_name: str, + config_server_settings: Union[_models.ConfigServerSettings, IO], + **kwargs: Any + ) -> LROPoller[_models.ConfigServerSettingsValidateResult]: + """Check if the config server settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param config_server_settings: Config server settings to be validated. Is either a model type + or a IO type. Required. + :type config_server_settings: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigServerSettingsValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigServerSettingsValidateResult] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigServerSettingsValidateResult] + 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._validate_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + config_server_settings=config_server_settings, + 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("ConfigServerSettingsValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configServers/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_configuration_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_configuration_services_operations.py new file mode 100644 index 000000000000..35e24ec0daf3 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_configuration_services_operations.py @@ -0,0 +1,996 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_name: str, configuration_service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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, service_name: str, configuration_service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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, service_name: str, configuration_service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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_request(resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_request( + resource_group_name: str, service_name: str, configuration_service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationServiceName": _SERIALIZER.url("configuration_service_name", configuration_service_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 ConfigurationServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`configuration_services` 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, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> _models.ConfigurationServiceResource: + """Get the Application Configuration Service and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationServiceResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], + **kwargs: Any + ) -> _models.ConfigurationServiceResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_service_resource, (IO, bytes)): + _content = configuration_service_resource + else: + _json = self._serialize.body(configuration_service_resource, "ConfigurationServiceResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: _models.ConfigurationServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Required. + :type configuration_service_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + configuration_service_resource: Union[_models.ConfigurationServiceResource, IO], + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceResource]: + """Create the default Application Configuration Service or update the existing Application + Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param configuration_service_resource: Parameters for the update operation. Is either a model + type or a IO type. Required. + :type configuration_service_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResource] + 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, + service_name=service_name, + configuration_service_name=configuration_service_name, + configuration_service_resource=configuration_service_resource, + 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("ConfigurationServiceResource", 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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, configuration_service_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, configuration_service_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Disable the default Application Configuration Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + configuration_service_name=configuration_service_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.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.ConfigurationServiceResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConfigurationServiceResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConfigurationServiceResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices"} # type: ignore + + def _validate_initial( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: Union[_models.ConfigurationServiceSettings, IO], + **kwargs: Any + ) -> _models.ConfigurationServiceSettingsValidateResult: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(settings, (IO, bytes)): + _content = settings + else: + _json = self._serialize.body(settings, "ConfigurationServiceSettings") + + request = build_validate_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._validate_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ConfigurationServiceSettingsValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: _models.ConfigurationServiceSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Required. + :type settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceSettingsValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_service_name: str, + settings: Union[_models.ConfigurationServiceSettings, IO], + **kwargs: Any + ) -> LROPoller[_models.ConfigurationServiceSettingsValidateResult]: + """Check if the Application Configuration Service settings are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param configuration_service_name: The name of Application Configuration Service. Required. + :type configuration_service_name: str + :param settings: Application Configuration Service settings to be validated. Is either a model + type or a IO type. Required. + :type settings: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceSettings + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either + ConfigurationServiceSettingsValidateResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ConfigurationServiceSettingsValidateResult] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationServiceSettingsValidateResult] + 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._validate_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + configuration_service_name=configuration_service_name, + settings=settings, + 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("ConfigurationServiceSettingsValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/configurationServices/{configurationServiceName}/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_custom_domains_operations.py new file mode 100644 index 000000000000..b097b0dc0784 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_custom_domains_operations.py @@ -0,0 +1,1034 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_name: str, app_name: str, domain_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, service_name: str, app_name: str, domain_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, service_name: str, app_name: str, domain_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, service_name: str, app_name: str, domain_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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) + + +def build_list_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", 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 CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`custom_domains` 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, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> _models.CustomDomainResource: + """Get the custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CustomDomainResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> _models.CustomDomainResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Create or update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + 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, + service_name=service_name, + app_name=app_name, + domain_name=domain_name, + domain_resource=domain_resource, + 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("CustomDomainResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, domain_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, domain_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + app_name=app_name, + domain_name=domain_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.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> _models.CustomDomainResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_resource, (IO, bytes)): + _content = domain_resource + else: + _json = self._serialize.body(domain_resource, "CustomDomainResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("CustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: _models.CustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Required. + :type domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + domain_name: str, + domain_resource: Union[_models.CustomDomainResource, IO], + **kwargs: Any + ) -> LROPoller[_models.CustomDomainResource]: + """Update custom domain of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param domain_name: The name of the custom domain resource. Required. + :type domain_name: str + :param domain_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type domain_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + domain_name=domain_name, + domain_resource=domain_resource, + 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("CustomDomainResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, app_name: str, **kwargs: Any + ) -> Iterable["_models.CustomDomainResource"]: + """List the custom domains of one lifecycle application. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type 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 CustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainResourceCollection] + + 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, + service_name=service_name, + app_name=app_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CustomDomainResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_customized_accelerators_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_customized_accelerators_operations.py new file mode 100644 index 000000000000..32f55f1ad411 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_customized_accelerators_operations.py @@ -0,0 +1,995 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, service_name: str, application_accelerator_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationAcceleratorName": _SERIALIZER.url( + "application_accelerator_name", application_accelerator_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, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationAcceleratorName": _SERIALIZER.url( + "application_accelerator_name", application_accelerator_name, "str" + ), + "customizedAcceleratorName": _SERIALIZER.url("customized_accelerator_name", customized_accelerator_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, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationAcceleratorName": _SERIALIZER.url( + "application_accelerator_name", application_accelerator_name, "str" + ), + "customizedAcceleratorName": _SERIALIZER.url("customized_accelerator_name", customized_accelerator_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, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationAcceleratorName": _SERIALIZER.url( + "application_accelerator_name", application_accelerator_name, "str" + ), + "customizedAcceleratorName": _SERIALIZER.url("customized_accelerator_name", customized_accelerator_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_validate_request( + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}/validate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationAcceleratorName": _SERIALIZER.url( + "application_accelerator_name", application_accelerator_name, "str" + ), + "customizedAcceleratorName": _SERIALIZER.url("customized_accelerator_name", customized_accelerator_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 CustomizedAcceleratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`customized_accelerators` 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, service_name: str, application_accelerator_name: str, **kwargs: Any + ) -> Iterable["_models.CustomizedAcceleratorResource"]: + """Handle requests to list all customized accelerators. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CustomizedAcceleratorResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomizedAcceleratorResourceCollection] + + 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, + service_name=service_name, + application_accelerator_name=application_accelerator_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CustomizedAcceleratorResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + **kwargs: Any + ) -> _models.CustomizedAcceleratorResource: + """Get the customized accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CustomizedAcceleratorResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomizedAcceleratorResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + customized_accelerator_name=customized_accelerator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomizedAcceleratorResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + customized_accelerator_resource: Union[_models.CustomizedAcceleratorResource, IO], + **kwargs: Any + ) -> _models.CustomizedAcceleratorResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomizedAcceleratorResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(customized_accelerator_resource, (IO, bytes)): + _content = customized_accelerator_resource + else: + _json = self._serialize.body(customized_accelerator_resource, "CustomizedAcceleratorResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + customized_accelerator_name=customized_accelerator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CustomizedAcceleratorResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CustomizedAcceleratorResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + customized_accelerator_resource: _models.CustomizedAcceleratorResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomizedAcceleratorResource]: + """Create or update the customized accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_name: str + :param customized_accelerator_resource: The customized accelerator for the create or update + operation. Required. + :type customized_accelerator_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomizedAcceleratorResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + customized_accelerator_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomizedAcceleratorResource]: + """Create or update the customized accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_name: str + :param customized_accelerator_resource: The customized accelerator for the create or update + operation. Required. + :type customized_accelerator_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomizedAcceleratorResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + customized_accelerator_resource: Union[_models.CustomizedAcceleratorResource, IO], + **kwargs: Any + ) -> LROPoller[_models.CustomizedAcceleratorResource]: + """Create or update the customized accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_name: str + :param customized_accelerator_resource: The customized accelerator for the create or update + operation. Is either a model type or a IO type. Required. + :type customized_accelerator_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CustomizedAcceleratorResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomizedAcceleratorResource] + 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, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + customized_accelerator_name=customized_accelerator_name, + customized_accelerator_resource=customized_accelerator_resource, + 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("CustomizedAcceleratorResource", 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.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + customized_accelerator_name=customized_accelerator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Delete the customized accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + customized_accelerator_name=customized_accelerator_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.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}"} # type: ignore + + @overload + def validate( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + properties: _models.CustomizedAcceleratorProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.CustomizedAcceleratorValidateResult]: + """Check the customized accelerator are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_name: str + :param properties: Customized accelerator properties to be validated. Required. + :type properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomizedAcceleratorValidateResult or None or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorValidateResult + or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.CustomizedAcceleratorValidateResult]: + """Check the customized accelerator are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_name: str + :param properties: Customized accelerator properties to be validated. Required. + :type properties: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomizedAcceleratorValidateResult or None or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorValidateResult + or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + customized_accelerator_name: str, + properties: Union[_models.CustomizedAcceleratorProperties, IO], + **kwargs: Any + ) -> Optional[_models.CustomizedAcceleratorValidateResult]: + """Check the customized accelerator are valid. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param customized_accelerator_name: The name of the customized accelerator. Required. + :type customized_accelerator_name: str + :param properties: Customized accelerator properties to be validated. Is either a model type or + a IO type. Required. + :type properties: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomizedAcceleratorValidateResult or None or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomizedAcceleratorValidateResult + or 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 = case_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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.CustomizedAcceleratorValidateResult]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "CustomizedAcceleratorProperties") + + request = build_validate_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + customized_accelerator_name=customized_accelerator_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("CustomizedAcceleratorValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/customizedAccelerators/{customizedAcceleratorName}/validate"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_deployments_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_deployments_operations.py new file mode 100644 index 000000000000..fa6a959d1d7d --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_deployments_operations.py @@ -0,0 +1,3216 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, + service_name: str, + app_name: str, + deployment_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, + service_name: str, + app_name: str, + deployment_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, + service_name: str, + app_name: str, + deployment_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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) + + +def build_list_request( + resource_group_name: str, + service_name: str, + app_name: str, + subscription_id: str, + *, + version: Optional[List[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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if version is not None: + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_for_cluster_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + version: Optional[List[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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if version is not None: + _params["version"] = [_SERIALIZER.query("version", q, "str") if q is not None else "" for q in version] + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_stop_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_restart_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_enable_remote_debugging_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/enableRemoteDebugging", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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) + + +def build_disable_remote_debugging_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/disableRemoteDebugging", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_remote_debugging_config_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getRemoteDebuggingConfig", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_log_file_url_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_generate_heap_dump_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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) + + +def build_generate_thread_dump_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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) + + +def build_start_jfr_request( + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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 DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`deployments` 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, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentResource: + """Get a Deployment and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> _models.DeploymentResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Create a new Deployment or update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the create or update operation. Is either a model + type or a IO type. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + 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, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + deployment_resource=deployment_resource, + 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("DeploymentResource", 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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Operation to delete a Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> _models.DeploymentResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_resource, (IO, bytes)): + _content = deployment_resource + else: + _json = self._serialize.body(deployment_resource, "DeploymentResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DeploymentResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: _models.DeploymentResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Required. + :type deployment_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + deployment_resource: Union[_models.DeploymentResource, IO], + **kwargs: Any + ) -> LROPoller[_models.DeploymentResource]: + """Operation to update an exiting Deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param deployment_resource: Parameters for the update operation. Is either a model type or a IO + type. Required. + :type deployment_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + deployment_resource=deployment_resource, + 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("DeploymentResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + app_name: str, + version: Optional[List[str]] = None, + **kwargs: Any + ) -> Iterable["_models.DeploymentResource"]: + """Handles requests to list all resources in an App. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param version: Version of the deployments to be listed. Default value is None. + :type version: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] + + 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, + service_name=service_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + version=version, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeploymentResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments"} # type: ignore + + @distributed_trace + def list_for_cluster( + self, resource_group_name: str, service_name: str, version: Optional[List[str]] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentResource"]: + """List deployments for a certain service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param version: Version of the deployments to be listed. Default value is None. + :type version: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.DeploymentResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentResourceCollection] + + 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_for_cluster_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + version=version, + api_version=api_version, + template_url=self.list_for_cluster.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeploymentResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_for_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/deployments"} # type: ignore + + def _start_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._start_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + + @distributed_trace + def begin_start( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Start the deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._start_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/start"} # type: ignore + + def _stop_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._stop_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + + @distributed_trace + def begin_stop( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Stop the deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._stop_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/stop"} # type: ignore + + def _restart_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, app_name: str, deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._restart_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + + @distributed_trace + def begin_restart( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Restart the deployment. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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._restart_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/restart"} # type: ignore + + def _enable_remote_debugging_initial( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[Union[_models.RemoteDebuggingPayload, IO]] = None, + **kwargs: Any + ) -> _models.RemoteDebugging: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(remote_debugging_payload, (IO, bytes)): + _content = remote_debugging_payload + else: + if remote_debugging_payload is not None: + _json = self._serialize.body(remote_debugging_payload, "RemoteDebuggingPayload") + else: + _json = None + + request = build_enable_remote_debugging_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._enable_remote_debugging_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _enable_remote_debugging_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/enableRemoteDebugging"} # type: ignore + + @overload + def begin_enable_remote_debugging( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[_models.RemoteDebuggingPayload] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RemoteDebugging]: + """Enable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param remote_debugging_payload: Parameters for enable remote debugging. Default value is None. + :type remote_debugging_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.RemoteDebuggingPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.RemoteDebugging] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_enable_remote_debugging( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RemoteDebugging]: + """Enable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param remote_debugging_payload: Parameters for enable remote debugging. Default value is None. + :type remote_debugging_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.RemoteDebugging] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_enable_remote_debugging( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + remote_debugging_payload: Optional[Union[_models.RemoteDebuggingPayload, IO]] = None, + **kwargs: Any + ) -> LROPoller[_models.RemoteDebugging]: + """Enable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param remote_debugging_payload: Parameters for enable remote debugging. Is either a model type + or a IO type. Default value is None. + :type remote_debugging_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.RemoteDebuggingPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.RemoteDebugging] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + 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._enable_remote_debugging_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + remote_debugging_payload=remote_debugging_payload, + 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("RemoteDebugging", 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_enable_remote_debugging.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/enableRemoteDebugging"} # type: ignore + + def _disable_remote_debugging_initial( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.RemoteDebugging: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + + request = build_disable_remote_debugging_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._disable_remote_debugging_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _disable_remote_debugging_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/disableRemoteDebugging"} # type: ignore + + @distributed_trace + def begin_disable_remote_debugging( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> LROPoller[_models.RemoteDebugging]: + """Disable remote debugging. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_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 RemoteDebugging or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.RemoteDebugging] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + 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._disable_remote_debugging_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_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): + deserialized = self._deserialize("RemoteDebugging", 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_disable_remote_debugging.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/disableRemoteDebugging"} # type: ignore + + @distributed_trace + def get_remote_debugging_config( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> _models.RemoteDebugging: + """Get remote debugging config. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RemoteDebugging or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.RemoteDebugging + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RemoteDebugging] + + request = build_get_remote_debugging_config_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_remote_debugging_config.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RemoteDebugging", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_remote_debugging_config.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getRemoteDebuggingConfig"} # type: ignore + + @distributed_trace + def get_log_file_url( + self, resource_group_name: str, service_name: str, app_name: str, deployment_name: str, **kwargs: Any + ) -> Optional[_models.LogFileUrlResponse]: + """Get deployment log file URL. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogFileUrlResponse or None or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.LogFileUrlResponse or 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.LogFileUrlResponse]] + + request = build_get_log_file_url_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_log_file_url.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("LogFileUrlResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_log_file_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/getLogFileUrl"} # type: ignore + + def _generate_heap_dump_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_heap_dump_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._generate_heap_dump_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _generate_heap_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + + @overload + def begin_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_heap_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Generate Heap Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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._generate_heap_dump_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + diagnostic_parameters=diagnostic_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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_generate_heap_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateHeapDump"} # type: ignore + + def _generate_thread_dump_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_generate_thread_dump_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._generate_thread_dump_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _generate_thread_dump_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + @overload + def begin_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_generate_thread_dump( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Generate Thread Dump. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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._generate_thread_dump_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + diagnostic_parameters=diagnostic_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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_generate_thread_dump.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/generateThreadDump"} # type: ignore + + def _start_jfr_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_parameters, (IO, bytes)): + _content = diagnostic_parameters + else: + _json = self._serialize.body(diagnostic_parameters, "DiagnosticParameters") + + request = build_start_jfr_request( + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._start_jfr_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_jfr_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore + + @overload + def begin_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: _models.DiagnosticParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DiagnosticParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Required. + :type diagnostic_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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_start_jfr( + self, + resource_group_name: str, + service_name: str, + app_name: str, + deployment_name: str, + diagnostic_parameters: Union[_models.DiagnosticParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Start JFR. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param app_name: The name of the App resource. Required. + :type app_name: str + :param deployment_name: The name of the Deployment resource. Required. + :type deployment_name: str + :param diagnostic_parameters: Parameters for the diagnostic operation. Is either a model type + or a IO type. Required. + :type diagnostic_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DiagnosticParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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._start_jfr_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + app_name=app_name, + deployment_name=deployment_name, + diagnostic_parameters=diagnostic_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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_start_jfr.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/deployments/{deploymentName}/startJFR"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_dev_tool_portals_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_dev_tool_portals_operations.py new file mode 100644 index 000000000000..d6649e528523 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_dev_tool_portals_operations.py @@ -0,0 +1,714 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/DevToolPortals", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_name: str, dev_tool_portal_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/DevToolPortals/{devToolPortalName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "devToolPortalName": _SERIALIZER.url("dev_tool_portal_name", dev_tool_portal_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, service_name: str, dev_tool_portal_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/DevToolPortals/{devToolPortalName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "devToolPortalName": _SERIALIZER.url("dev_tool_portal_name", dev_tool_portal_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, service_name: str, dev_tool_portal_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/DevToolPortals/{devToolPortalName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "devToolPortalName": _SERIALIZER.url("dev_tool_portal_name", dev_tool_portal_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 DevToolPortalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`dev_tool_portals` 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, service_name: str, **kwargs: Any + ) -> Iterable["_models.DevToolPortalResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DevToolPortalResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DevToolPortalResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DevToolPortalResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/DevToolPortals"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, dev_tool_portal_name: str, **kwargs: Any + ) -> _models.DevToolPortalResource: + """Get the Application Live and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param dev_tool_portal_name: The name of Dev Tool Portal. Required. + :type dev_tool_portal_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DevToolPortalResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DevToolPortalResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + dev_tool_portal_name=dev_tool_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DevToolPortalResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/DevToolPortals/{devToolPortalName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + dev_tool_portal_name: str, + dev_tool_portal_resource: Union[_models.DevToolPortalResource, IO], + **kwargs: Any + ) -> _models.DevToolPortalResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DevToolPortalResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(dev_tool_portal_resource, (IO, bytes)): + _content = dev_tool_portal_resource + else: + _json = self._serialize.body(dev_tool_portal_resource, "DevToolPortalResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + dev_tool_portal_name=dev_tool_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DevToolPortalResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("DevToolPortalResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/DevToolPortals/{devToolPortalName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + dev_tool_portal_name: str, + dev_tool_portal_resource: _models.DevToolPortalResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DevToolPortalResource]: + """Create the default Dev Tool Portal or update the existing Dev Tool Portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param dev_tool_portal_name: The name of Dev Tool Portal. Required. + :type dev_tool_portal_name: str + :param dev_tool_portal_resource: Parameters for the create or update operation. Required. + :type dev_tool_portal_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DevToolPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + dev_tool_portal_name: str, + dev_tool_portal_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DevToolPortalResource]: + """Create the default Dev Tool Portal or update the existing Dev Tool Portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param dev_tool_portal_name: The name of Dev Tool Portal. Required. + :type dev_tool_portal_name: str + :param dev_tool_portal_resource: Parameters for the create or update operation. Required. + :type dev_tool_portal_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DevToolPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + dev_tool_portal_name: str, + dev_tool_portal_resource: Union[_models.DevToolPortalResource, IO], + **kwargs: Any + ) -> LROPoller[_models.DevToolPortalResource]: + """Create the default Dev Tool Portal or update the existing Dev Tool Portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param dev_tool_portal_name: The name of Dev Tool Portal. Required. + :type dev_tool_portal_name: str + :param dev_tool_portal_resource: Parameters for the create or update operation. Is either a + model type or a IO type. Required. + :type dev_tool_portal_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DevToolPortalResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.DevToolPortalResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DevToolPortalResource] + 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, + service_name=service_name, + dev_tool_portal_name=dev_tool_portal_name, + dev_tool_portal_resource=dev_tool_portal_resource, + 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("DevToolPortalResource", 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.AppPlatform/Spring/{serviceName}/DevToolPortals/{devToolPortalName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, dev_tool_portal_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + dev_tool_portal_name=dev_tool_portal_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/DevToolPortals/{devToolPortalName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, dev_tool_portal_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Disable the default Dev Tool Portal. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param dev_tool_portal_name: The name of Dev Tool Portal. Required. + :type dev_tool_portal_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + dev_tool_portal_name=dev_tool_portal_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.AppPlatform/Spring/{serviceName}/DevToolPortals/{devToolPortalName}"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_gateway_custom_domains_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_gateway_custom_domains_operations.py new file mode 100644 index 000000000000..d9db8dbf6a75 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_gateway_custom_domains_operations.py @@ -0,0 +1,759 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, + service_name: str, + gateway_name: str, + domain_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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, + service_name: str, + gateway_name: str, + domain_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_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_request( + resource_group_name: str, service_name: str, gateway_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewayCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`gateway_custom_domains` 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, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any + ) -> _models.GatewayCustomDomainResource: + """Get the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayCustomDomainResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], + **kwargs: Any + ) -> _models.GatewayCustomDomainResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_custom_domain_resource, (IO, bytes)): + _content = gateway_custom_domain_resource + else: + _json = self._serialize.body(gateway_custom_domain_resource, "GatewayCustomDomainResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GatewayCustomDomainResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: _models.GatewayCustomDomainResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayCustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Required. + :type gateway_custom_domain_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayCustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + domain_name: str, + gateway_custom_domain_resource: Union[_models.GatewayCustomDomainResource, IO], + **kwargs: Any + ) -> LROPoller[_models.GatewayCustomDomainResource]: + """Create or update the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_name: str + :param gateway_custom_domain_resource: The gateway custom domain resource for the create or + update operation. Is either a model type or a IO type. Required. + :type gateway_custom_domain_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayCustomDomainResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResource] + 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, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_name, + gateway_custom_domain_resource=gateway_custom_domain_resource, + 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("GatewayCustomDomainResource", 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, gateway_name: str, domain_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, domain_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the Spring Cloud Gateway custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param domain_name: The name of the Spring Cloud Gateway custom domain. Required. + :type domain_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + gateway_name=gateway_name, + domain_name=domain_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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains/{domainName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> Iterable["_models.GatewayCustomDomainResource"]: + """Handle requests to list all Spring Cloud Gateway custom domains. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayCustomDomainResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayCustomDomainResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCustomDomainResourceCollection] + + 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, + service_name=service_name, + gateway_name=gateway_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GatewayCustomDomainResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/domains"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_gateway_route_configs_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_gateway_route_configs_operations.py new file mode 100644 index 000000000000..28bef4bf314a --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_gateway_route_configs_operations.py @@ -0,0 +1,762 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_config_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, + service_name: str, + gateway_name: str, + route_config_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_config_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, + service_name: str, + gateway_name: str, + route_config_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "routeConfigName": _SERIALIZER.url("route_config_name", route_config_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_request( + resource_group_name: str, service_name: str, gateway_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewayRouteConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`gateway_route_configs` 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, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any + ) -> _models.GatewayRouteConfigResource: + """Get the Spring Cloud Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayRouteConfigResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], + **kwargs: Any + ) -> _models.GatewayRouteConfigResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_route_config_resource, (IO, bytes)): + _content = gateway_route_config_resource + else: + _json = self._serialize.body(gateway_route_config_resource, "GatewayRouteConfigResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GatewayRouteConfigResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: _models.GatewayRouteConfigResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayRouteConfigResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Required. + :type gateway_route_config_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayRouteConfigResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + route_config_name: str, + gateway_route_config_resource: Union[_models.GatewayRouteConfigResource, IO], + **kwargs: Any + ) -> LROPoller[_models.GatewayRouteConfigResource]: + """Create the default Spring Cloud Gateway route configs or update the existing Spring Cloud + Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_name: str + :param gateway_route_config_resource: The Spring Cloud Gateway route config for the create or + update operation. Is either a model type or a IO type. Required. + :type gateway_route_config_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayRouteConfigResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResource] + 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, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_name, + gateway_route_config_resource=gateway_route_config_resource, + 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("GatewayRouteConfigResource", 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, route_config_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the Spring Cloud Gateway route config. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param route_config_name: The name of the Spring Cloud Gateway route config. Required. + :type route_config_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + gateway_name=gateway_name, + route_config_name=route_config_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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs/{routeConfigName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> Iterable["_models.GatewayRouteConfigResource"]: + """Handle requests to list all Spring Cloud Gateway route configs. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayRouteConfigResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayRouteConfigResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayRouteConfigResourceCollection] + + 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, + service_name=service_name, + gateway_name=gateway_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GatewayRouteConfigResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/routeConfigs"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_gateways_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_gateways_operations.py new file mode 100644 index 000000000000..8d51927ce121 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_gateways_operations.py @@ -0,0 +1,1000 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_name: str, gateway_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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, service_name: str, gateway_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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, service_name: str, gateway_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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_env_secrets_request( + resource_group_name: str, service_name: str, gateway_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/listEnvSecrets", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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_list_request(resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_validate_domain_request( + resource_group_name: str, service_name: str, gateway_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_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 GatewaysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`gateways` 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, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> _models.GatewayResource: + """Get the Spring Cloud Gateway and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GatewayResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: Union[_models.GatewayResource, IO], + **kwargs: Any + ) -> _models.GatewayResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gateway_resource, (IO, bytes)): + _content = gateway_resource + else: + _json = self._serialize.body(gateway_resource, "GatewayResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GatewayResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GatewayResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: _models.GatewayResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Required. + :type gateway_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + gateway_resource: Union[_models.GatewayResource, IO], + **kwargs: Any + ) -> LROPoller[_models.GatewayResource]: + """Create the default Spring Cloud Gateway or update the existing Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param gateway_resource: The gateway for the create or update operation. Is either a model type + or a IO type. Required. + :type gateway_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GatewayResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResource] + 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, + service_name=service_name, + gateway_name=gateway_name, + gateway_resource=gateway_resource, + 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("GatewayResource", 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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, gateway_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Disable the default Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + gateway_name=gateway_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.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}"} # type: ignore + + @distributed_trace + def list_env_secrets( + self, resource_group_name: str, service_name: str, gateway_name: str, **kwargs: Any + ) -> Dict[str, str]: + """List sensitive environment variables of Spring Cloud Gateway. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str or the result of cls(response) + :rtype: dict[str, str] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + + request = build_list_env_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_env_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_env_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/listEnvSecrets"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.GatewayResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.GatewayResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GatewayResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways"} # type: ignore + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: _models.CustomDomainValidatePayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidatePayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Required. + :type validate_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_domain( + self, + resource_group_name: str, + service_name: str, + gateway_name: str, + validate_payload: Union[_models.CustomDomainValidatePayload, IO], + **kwargs: Any + ) -> _models.CustomDomainValidateResult: + """Check the domains are valid as well as not in use. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param gateway_name: The name of Spring Cloud Gateway. Required. + :type gateway_name: str + :param validate_payload: Custom domain payload to be validated. Is either a model type or a IO + type. Required. + :type validate_payload: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidatePayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: CustomDomainValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.CustomDomainValidateResult + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_payload, (IO, bytes)): + _content = validate_payload + else: + _json = self._serialize.body(validate_payload, "CustomDomainValidatePayload") + + request = build_validate_domain_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate_domain.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomDomainValidateResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/gateways/{gatewayName}/validateDomain"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_monitoring_settings_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_monitoring_settings_operations.py new file mode 100644 index 000000000000..c0e9c38ac59e --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_monitoring_settings_operations.py @@ -0,0 +1,683 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_put_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_update_patch_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/monitoringSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 MonitoringSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`monitoring_settings` 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, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.MonitoringSettingResource: + """Get the Monitoring Setting and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + def _update_put_initial( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> _models.MonitoringSettingResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_put_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_put_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_put_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_put( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_put_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + monitoring_setting_resource=monitoring_setting_resource, + 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("MonitoringSettingResource", 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_update_put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + def _update_patch_initial( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> _models.MonitoringSettingResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_setting_resource, (IO, bytes)): + _content = monitoring_setting_resource + else: + _json = self._serialize.body(monitoring_setting_resource, "MonitoringSettingResource") + + request = build_update_patch_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_patch_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("MonitoringSettingResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_patch_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: _models.MonitoringSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Required. + :type monitoring_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_patch( + self, + resource_group_name: str, + service_name: str, + monitoring_setting_resource: Union[_models.MonitoringSettingResource, IO], + **kwargs: Any + ) -> LROPoller[_models.MonitoringSettingResource]: + """Update the Monitoring Setting. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param monitoring_setting_resource: Parameters for the update operation. Is either a model type + or a IO type. Required. + :type monitoring_setting_resource: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringSettingResource or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.MonitoringSettingResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitoringSettingResource] + 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_patch_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + monitoring_setting_resource=monitoring_setting_resource, + 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("MonitoringSettingResource", 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_update_patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_operations.py new file mode 100644 index 000000000000..df6758be1ea8 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_operations.py @@ -0,0 +1,163 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/operations") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.OperationDetail"]: + """Lists all of the available REST API operations of the Microsoft.AppPlatform provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationDetail or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.OperationDetail] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableOperations] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AvailableOperations", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.AppPlatform/operations"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_patch.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_predefined_accelerators_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_predefined_accelerators_operations.py new file mode 100644 index 000000000000..e7ba0568a51c --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_predefined_accelerators_operations.py @@ -0,0 +1,654 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, service_name: str, application_accelerator_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationAcceleratorName": _SERIALIZER.url( + "application_accelerator_name", application_accelerator_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, + service_name: str, + application_accelerator_name: str, + predefined_accelerator_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators/{predefinedAcceleratorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationAcceleratorName": _SERIALIZER.url( + "application_accelerator_name", application_accelerator_name, "str" + ), + "predefinedAcceleratorName": _SERIALIZER.url("predefined_accelerator_name", predefined_accelerator_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_disable_request( + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + predefined_accelerator_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators/{predefinedAcceleratorName}/disable", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationAcceleratorName": _SERIALIZER.url( + "application_accelerator_name", application_accelerator_name, "str" + ), + "predefinedAcceleratorName": _SERIALIZER.url("predefined_accelerator_name", predefined_accelerator_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_enable_request( + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + predefined_accelerator_name: str, + 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators/{predefinedAcceleratorName}/enable", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "applicationAcceleratorName": _SERIALIZER.url( + "application_accelerator_name", application_accelerator_name, "str" + ), + "predefinedAcceleratorName": _SERIALIZER.url("predefined_accelerator_name", predefined_accelerator_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 PredefinedAcceleratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`predefined_accelerators` 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, service_name: str, application_accelerator_name: str, **kwargs: Any + ) -> Iterable["_models.PredefinedAcceleratorResource"]: + """Handle requests to list all predefined accelerators. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PredefinedAcceleratorResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.PredefinedAcceleratorResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PredefinedAcceleratorResourceCollection] + + 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, + service_name=service_name, + application_accelerator_name=application_accelerator_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PredefinedAcceleratorResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + predefined_accelerator_name: str, + **kwargs: Any + ) -> _models.PredefinedAcceleratorResource: + """Get the predefined accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param predefined_accelerator_name: The name of the predefined accelerator. Required. + :type predefined_accelerator_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PredefinedAcceleratorResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.PredefinedAcceleratorResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PredefinedAcceleratorResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + predefined_accelerator_name=predefined_accelerator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PredefinedAcceleratorResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators/{predefinedAcceleratorName}"} # type: ignore + + def _disable_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + predefined_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_disable_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + predefined_accelerator_name=predefined_accelerator_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._disable_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _disable_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators/{predefinedAcceleratorName}/disable"} # type: ignore + + @distributed_trace + def begin_disable( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + predefined_accelerator_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Disable predefined accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param predefined_accelerator_name: The name of the predefined accelerator. Required. + :type predefined_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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._disable_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + predefined_accelerator_name=predefined_accelerator_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_disable.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators/{predefinedAcceleratorName}/disable"} # type: ignore + + def _enable_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + predefined_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_enable_request( + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + predefined_accelerator_name=predefined_accelerator_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._enable_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _enable_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators/{predefinedAcceleratorName}/enable"} # type: ignore + + @distributed_trace + def begin_enable( + self, + resource_group_name: str, + service_name: str, + application_accelerator_name: str, + predefined_accelerator_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Enable predefined accelerator. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param application_accelerator_name: The name of the application accelerator. Required. + :type application_accelerator_name: str + :param predefined_accelerator_name: The name of the predefined accelerator. Required. + :type predefined_accelerator_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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._enable_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + application_accelerator_name=application_accelerator_name, + predefined_accelerator_name=predefined_accelerator_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_enable.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/applicationAccelerators/{applicationAcceleratorName}/predefinedAccelerators/{predefinedAcceleratorName}/enable"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_runtime_versions_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_runtime_versions_operations.py new file mode 100644 index 000000000000..fca82bfad937 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_runtime_versions_operations.py @@ -0,0 +1,133 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, 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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_runtime_versions_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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.AppPlatform/runtimeVersions") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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 RuntimeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`runtime_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_runtime_versions(self, **kwargs: Any) -> _models.AvailableRuntimeVersions: + """Lists all of the available runtime versions supported by Microsoft.AppPlatform provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AvailableRuntimeVersions or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.AvailableRuntimeVersions + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableRuntimeVersions] + + request = build_list_runtime_versions_request( + api_version=api_version, + template_url=self.list_runtime_versions.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AvailableRuntimeVersions", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_runtime_versions.metadata = {"url": "/providers/Microsoft.AppPlatform/runtimeVersions"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_service_registries_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_service_registries_operations.py new file mode 100644 index 000000000000..072c140fb8bc --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_service_registries_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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, service_name: str, service_registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "serviceRegistryName": _SERIALIZER.url("service_registry_name", service_registry_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_request(resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 ServiceRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`service_registries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: + """Get the Service Registry and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param service_registry_name: The name of Service Registry. Required. + :type service_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServiceRegistryResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceRegistryResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + def _create_or_update_initial( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> _models.ServiceRegistryResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ServiceRegistryResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> LROPoller[_models.ServiceRegistryResource]: + """Create the default Service Registry or update the existing Service Registry. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param service_registry_name: The name of Service Registry. Required. + :type service_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceRegistryResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceRegistryResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResource] + 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, + service_name=service_name, + service_registry_name=service_registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ServiceRegistryResource", 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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + service_registry_name=service_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, service_registry_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Disable the default Service Registry. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param service_registry_name: The name of Service Registry. Required. + :type service_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + service_registry_name=service_registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = 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.AppPlatform/Spring/{serviceName}/serviceRegistries/{serviceRegistryName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.ServiceRegistryResource"]: + """Handles requests to list all resources in a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServiceRegistryResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceRegistryResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceRegistryResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceRegistryResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/serviceRegistries"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_services_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_services_operations.py new file mode 100644 index 000000000000..950091d0030f --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_services_operations.py @@ -0,0 +1,1933 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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) + + +def build_list_test_keys_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_regenerate_test_key_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/regenerateTestKey", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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) + + +def build_disable_test_endpoint_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_enable_test_endpoint_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_stop_request(resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_start_request( + resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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_check_name_availability_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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "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) + + +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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`services` 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, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ServiceResource: + """Get a Service and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServiceResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + def _create_or_update_initial( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + resource: _models.ServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Create a new Service or update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the create or update operation. Is either a model type or a IO + type. Required. + :type resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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, + service_name=service_name, + resource=resource, + 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("ServiceResource", 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.AppPlatform/Spring/{serviceName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: + """Operation to delete a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_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.AppPlatform/Spring/{serviceName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> _models.ServiceResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ServiceResource") + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("ServiceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: _models.ServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, service_name: str, resource: Union[_models.ServiceResource, IO], **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Operation to update an exiting Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param resource: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServiceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + resource=resource, + 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("ServiceResource", 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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}"} # type: ignore + + @distributed_trace + def list_test_keys(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: + """List test keys for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.TestKeys + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + request = build_list_test_keys_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_test_keys.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_test_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys"} # type: ignore + + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: _models.RegenerateTestKeyRequestPayload, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.RegenerateTestKeyRequestPayload + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Required. + :type regenerate_test_key_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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.TestKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_test_key( + self, + resource_group_name: str, + service_name: str, + regenerate_test_key_request: Union[_models.RegenerateTestKeyRequestPayload, IO], + **kwargs: Any + ) -> _models.TestKeys: + """Regenerate a test key for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param regenerate_test_key_request: Parameters for the operation. Is either a model type or a + IO type. Required. + :type regenerate_test_key_request: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.RegenerateTestKeyRequestPayload or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.TestKeys + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_test_key_request, (IO, bytes)): + _content = regenerate_test_key_request + else: + _json = self._serialize.body(regenerate_test_key_request, "RegenerateTestKeyRequestPayload") + + request = build_regenerate_test_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.regenerate_test_key.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_test_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey"} # type: ignore + + @distributed_trace + def disable_test_endpoint( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + """Disable test endpoint functionality for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_disable_test_endpoint_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.disable_test_endpoint.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + disable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint"} # type: ignore + + @distributed_trace + def enable_test_endpoint(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.TestKeys: + """Enable test endpoint functionality for a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestKeys or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.TestKeys + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestKeys] + + request = build_enable_test_endpoint_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.enable_test_endpoint.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + enable_test_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint"} # type: ignore + + def _stop_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._stop_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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + + @distributed_trace + def begin_stop(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: + """Stop a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._stop_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_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_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/stop"} # type: ignore + + def _start_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + 409: lambda response: ResourceExistsError(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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._start_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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + + @distributed_trace + def begin_start(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: + """Start a Service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._start_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_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_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/start"} # type: ignore + + @overload + def check_name_availability( + self, + location: str, + availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Required. + :type availability_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, location: str, availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param availability_parameters: Parameters supplied to the operation. Is either a model type or + a IO type. Required. + :type availability_parameters: + ~azure.mgmt.appplatform.v2022_11_01_preview.models.NameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.NameAvailability + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(availability_parameters, (IO, bytes)): + _content = availability_parameters + else: + _json = self._serialize.body(availability_parameters, "NameAvailabilityParameters") + + request = build_check_name_availability_request( + location=location, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NameAvailability", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability"} # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ServiceResource"]: + """Handles requests to list all resources in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServiceResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] + + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceResourceList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ServiceResource"]: + """Handles requests to list all resources in a resource group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. 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 ServiceResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ServiceResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] + + 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, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceResourceList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_skus_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_skus_operations.py new file mode 100644 index 000000000000..fd78d78addf3 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_skus_operations.py @@ -0,0 +1,169 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`skus` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.ResourceSku"]: + """Lists all of the available skus of the Microsoft.AppPlatform provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceSku or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.ResourceSku] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceSkuCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/skus"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_storages_operations.py b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_storages_operations.py new file mode 100644 index 000000000000..f1f0bdb237db --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/operations/_storages_operations.py @@ -0,0 +1,713 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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, service_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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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) + + +def build_list_request(resource_group_name: str, service_name: str, 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-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_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 StoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appplatform.v2022_11_01_preview.AppPlatformManagementClient`'s + :attr:`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 get( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> _models.StorageResource: + """Get the storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageResource or the result of cls(response) + :rtype: ~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: Union[_models.StorageResource, IO], + **kwargs: Any + ) -> _models.StorageResource: + 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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_resource, (IO, bytes)): + _content = storage_resource + else: + _json = self._serialize.body(storage_resource, "StorageResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_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_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("StorageResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("StorageResource", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("StorageResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: _models.StorageResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Required. + :type storage_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + storage_name: str, + storage_resource: Union[_models.StorageResource, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageResource]: + """Create or update storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_name: str + :param storage_resource: Parameters for the create or update operation. Is either a model type + or a IO type. Required. + :type storage_resource: ~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResource] + 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, + service_name=service_name, + storage_name=storage_name, + storage_resource=storage_resource, + 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("StorageResource", 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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, storage_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + storage_name=storage_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, service_name: str, storage_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the storage resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :param storage_name: The name of the storage resource. Required. + :type storage_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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + 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, + service_name=service_name, + storage_name=storage_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.AppPlatform/Spring/{serviceName}/storages/{storageName}"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterable["_models.StorageResource"]: + """List all the storages of one Azure Spring Apps resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param service_name: The name of the Service resource. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StorageResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appplatform.v2022_11_01_preview.models.StorageResource] + :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", "2022-11-01-preview") + ) # type: Literal["2022-11-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageResourceCollection] + + 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, + service_name=service_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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageResourceCollection", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/storages"} # type: ignore diff --git a/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/py.typed b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/appplatform/azure-mgmt-appplatform/azure/mgmt/appplatform/v2022_11_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/devcenter/azure-mgmt-devcenter/CHANGELOG.md b/sdk/devcenter/azure-mgmt-devcenter/CHANGELOG.md index 49eca789f19f..24788cd29ea3 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/CHANGELOG.md +++ b/sdk/devcenter/azure-mgmt-devcenter/CHANGELOG.md @@ -1,5 +1,19 @@ # Release History +## 1.0.0b3 (2022-11-08) + +### Features Added + + - Model Catalog has a new parameter sync_state + - Model CatalogProperties has a new parameter sync_state + - Model OperationStatus has a new parameter operations + - Model OperationStatus has a new parameter resource_id + +### Breaking Changes + + - Client name is changed from `DevCenterClient` to `DevCenterMgmtClient` + - Parameter status of model OperationStatus is now required + ## 1.0.0b2 (2022-09-29) ### Features Added diff --git a/sdk/devcenter/azure-mgmt-devcenter/_meta.json b/sdk/devcenter/azure-mgmt-devcenter/_meta.json index 763669569726..5973e61f4103 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/_meta.json +++ b/sdk/devcenter/azure-mgmt-devcenter/_meta.json @@ -1,11 +1,11 @@ { + "commit": "4903b1ed79e30f689d7c469cfa06734cfcd106d6", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.2", "use": [ - "@autorest/python@6.1.6", + "@autorest/python@6.2.1", "@autorest/modelerfour@4.24.3" ], - "commit": "14677ba21f6b5676e79b33d699f7a103dd8f255f", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/devcenter/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.1.6 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/devcenter/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.2.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/devcenter/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/__init__.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/__init__.py index b57cb3e868af..51bb82fc2891 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/__init__.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/__init__.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._dev_center_client import DevCenterClient +from ._dev_center_mgmt_client import DevCenterMgmtClient from ._version import VERSION __version__ = VERSION @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["DevCenterClient"] +__all__ = [ + "DevCenterMgmtClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/_configuration.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/_configuration.py index e36f4196bff3..397abfc289d7 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/_configuration.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,30 +15,34 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class DevCenterClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for DevCenterClient. +class DevCenterMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for DevCenterMgmtClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Unique identifier of the Azure subscription. This is a GUID-formatted - string (e.g. 00000000-0000-0000-0000-000000000000). Required. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-09-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2022-10-12-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(DevCenterClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-09-01-preview") # type: str + super(DevCenterMgmtClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-10-12-preview") # type: Literal["2022-10-12-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/_dev_center_client.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/_dev_center_mgmt_client.py similarity index 93% rename from sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/_dev_center_client.py rename to sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/_dev_center_mgmt_client.py index 4a501c1b7ac5..3dfe7e46c697 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/_dev_center_client.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/_dev_center_mgmt_client.py @@ -13,7 +13,7 @@ from azure.mgmt.core import ARMPipelineClient from . import models -from ._configuration import DevCenterClientConfiguration +from ._configuration import DevCenterMgmtClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( AttachedNetworksOperations, @@ -41,7 +41,7 @@ from azure.core.credentials import TokenCredential -class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class DevCenterMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """DevCenter Management API. :ivar dev_centers: DevCentersOperations operations @@ -84,12 +84,11 @@ class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword,too :vartype network_connections: azure.mgmt.devcenter.operations.NetworkConnectionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Unique identifier of the Azure subscription. This is a GUID-formatted - string (e.g. 00000000-0000-0000-0000-000000000000). Required. + :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-09-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2022-10-12-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 @@ -103,7 +102,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = DevCenterClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = DevCenterMgmtClientConfiguration( + 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)} @@ -170,7 +171,7 @@ def close(self): self._client.close() def __enter__(self): - # type: () -> DevCenterClient + # type: () -> DevCenterMgmtClient self._client.__enter__() return self diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/_version.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/_version.py index dfa6ee022f15..20971492f129 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/_version.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b2" +VERSION = "1.0.0b3" diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/__init__.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/__init__.py index bbdaee71b1a1..b3e56c6d14df 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/__init__.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/__init__.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._dev_center_client import DevCenterClient +from ._dev_center_mgmt_client import DevCenterMgmtClient try: from ._patch import __all__ as _patch_all @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["DevCenterClient"] +__all__ = [ + "DevCenterMgmtClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/_configuration.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/_configuration.py index d32e37a3dff4..84457ecc8334 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/_configuration.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,30 +15,34 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class DevCenterClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for DevCenterClient. +class DevCenterMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for DevCenterMgmtClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Unique identifier of the Azure subscription. This is a GUID-formatted - string (e.g. 00000000-0000-0000-0000-000000000000). Required. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-09-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2022-10-12-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(DevCenterClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-09-01-preview") # type: str + super(DevCenterMgmtClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-10-12-preview") # type: Literal["2022-10-12-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/_dev_center_client.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/_dev_center_mgmt_client.py similarity index 93% rename from sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/_dev_center_client.py rename to sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/_dev_center_mgmt_client.py index 00e9cffa4c27..28276733e012 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/_dev_center_client.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/_dev_center_mgmt_client.py @@ -14,7 +14,7 @@ from .. import models from .._serialization import Deserializer, Serializer -from ._configuration import DevCenterClientConfiguration +from ._configuration import DevCenterMgmtClientConfiguration from .operations import ( AttachedNetworksOperations, CatalogsOperations, @@ -41,7 +41,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class DevCenterMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """DevCenter Management API. :ivar dev_centers: DevCentersOperations operations @@ -84,12 +84,11 @@ class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword,too :vartype network_connections: azure.mgmt.devcenter.aio.operations.NetworkConnectionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Unique identifier of the Azure subscription. This is a GUID-formatted - string (e.g. 00000000-0000-0000-0000-000000000000). Required. + :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-09-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2022-10-12-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 @@ -103,7 +102,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = DevCenterClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = DevCenterMgmtClientConfiguration( + 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)} @@ -168,7 +169,7 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "DevCenterClient": + async def __aenter__(self) -> "DevCenterMgmtClient": await self._client.__aenter__() return self diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_attached_networks_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_attached_networks_operations.py index 6d853481959a..2dff679c5437 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_attached_networks_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_attached_networks_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -39,6 +40,10 @@ build_list_by_project_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +54,7 @@ class AttachedNetworksOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`attached_networks` attribute. """ @@ -68,7 +73,8 @@ def list_by_project( ) -> AsyncIterable["_models.AttachedNetworkConnection"]: """Lists the attached NetworkConnections for a Project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -85,7 +91,9 @@ def list_by_project( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedNetworkListResult] error_map = { @@ -114,10 +122,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -154,7 +169,8 @@ async def get_by_project( ) -> _models.AttachedNetworkConnection: """Gets an attached NetworkConnection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -176,7 +192,9 @@ async def get_by_project( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedNetworkConnection] request = build_get_by_project_request( @@ -217,7 +235,8 @@ def list_by_dev_center( ) -> AsyncIterable["_models.AttachedNetworkConnection"]: """Lists the attached NetworkConnections for a DevCenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -234,7 +253,9 @@ def list_by_dev_center( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedNetworkListResult] error_map = { @@ -263,10 +284,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -303,7 +331,8 @@ async def get_by_dev_center( ) -> _models.AttachedNetworkConnection: """Gets an attached NetworkConnection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -325,7 +354,9 @@ async def get_by_dev_center( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedNetworkConnection] request = build_get_by_dev_center_request( @@ -379,7 +410,9 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedNetworkConnection] @@ -439,7 +472,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.AttachedNetworkConnection]: """Creates or updates an attached NetworkConnection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -478,7 +512,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.AttachedNetworkConnection]: """Creates or updates an attached NetworkConnection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -515,7 +550,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.AttachedNetworkConnection]: """Creates or updates an attached NetworkConnection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -544,7 +580,9 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedNetworkConnection] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -605,7 +643,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -642,7 +682,8 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Un-attach a NetworkConnection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -663,7 +704,9 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_catalogs_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_catalogs_operations.py index 97ef62517dc2..1716cc090c3d 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_catalogs_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_catalogs_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -39,6 +40,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +54,7 @@ class CatalogsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`catalogs` attribute. """ @@ -68,7 +73,8 @@ def list_by_dev_center( ) -> AsyncIterable["_models.Catalog"]: """Lists catalogs for a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -83,7 +89,9 @@ def list_by_dev_center( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.CatalogListResult] error_map = { @@ -112,10 +120,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -152,7 +167,8 @@ async def get( ) -> _models.Catalog: """Gets a catalog. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -174,7 +190,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Catalog] request = build_get_request( @@ -228,7 +246,9 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Catalog] @@ -288,7 +308,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Catalog]: """Creates or updates a catalog. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -326,7 +347,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Catalog]: """Creates or updates a catalog. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -362,7 +384,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Catalog]: """Creates or updates a catalog. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -389,7 +412,9 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Catalog] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -455,7 +480,9 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Catalog]] @@ -517,7 +544,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.Catalog]: """Partially updates a catalog. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -555,7 +583,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.Catalog]: """Partially updates a catalog. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -591,7 +620,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.Catalog]: """Partially updates a catalog. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -618,7 +648,9 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Catalog] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -679,7 +711,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -716,7 +750,8 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Deletes a catalog resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -737,7 +772,9 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) @@ -793,7 +830,9 @@ async def _sync_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_sync_request( @@ -830,7 +869,8 @@ async def begin_sync( ) -> AsyncLROPoller[None]: """Syncs templates for a template source. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -851,7 +891,9 @@ async def begin_sync( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) @@ -875,7 +917,8 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- if polling is True: polling_method = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), ) # type: AsyncPollingMethod elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_dev_box_definitions_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_dev_box_definitions_operations.py index fa496a4ecc05..dad12e3e90dd 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_dev_box_definitions_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_dev_box_definitions_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +55,7 @@ class DevBoxDefinitionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`dev_box_definitions` attribute. """ @@ -69,7 +74,8 @@ def list_by_dev_center( ) -> AsyncIterable["_models.DevBoxDefinition"]: """List Dev Box definitions for a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -84,7 +90,9 @@ def list_by_dev_center( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevBoxDefinitionListResult] error_map = { @@ -113,10 +121,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -153,7 +168,8 @@ async def get( ) -> _models.DevBoxDefinition: """Gets a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -175,7 +191,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevBoxDefinition] request = build_get_request( @@ -229,7 +247,9 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevBoxDefinition] @@ -293,7 +313,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.DevBoxDefinition]: """Creates or updates a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -331,7 +352,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.DevBoxDefinition]: """Creates or updates a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -367,7 +389,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.DevBoxDefinition]: """Creates or updates a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -394,7 +417,9 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevBoxDefinition] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -460,7 +485,9 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DevBoxDefinition]] @@ -522,7 +549,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.DevBoxDefinition]: """Partially updates a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -560,7 +588,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.DevBoxDefinition]: """Partially updates a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -596,7 +625,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.DevBoxDefinition]: """Partially updates a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -623,7 +653,9 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevBoxDefinition] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -684,7 +716,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -721,7 +755,8 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Deletes a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -742,7 +777,9 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) @@ -790,7 +827,8 @@ def list_by_project( ) -> AsyncIterable["_models.DevBoxDefinition"]: """List Dev Box definitions configured for a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -805,7 +843,9 @@ def list_by_project( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevBoxDefinitionListResult] error_map = { @@ -834,10 +874,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -874,7 +921,8 @@ async def get_by_project( ) -> _models.DevBoxDefinition: """Gets a Dev Box definition configured for a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -896,7 +944,9 @@ async def get_by_project( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevBoxDefinition] request = build_get_by_project_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_dev_centers_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_dev_centers_operations.py index 9af89b18d13c..6525a35c2c40 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_dev_centers_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_dev_centers_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -39,6 +40,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +54,7 @@ class DevCentersOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`dev_centers` attribute. """ @@ -77,7 +82,9 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevCenterListResult] error_map = { @@ -104,10 +111,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -144,7 +158,8 @@ def list_by_resource_group( ) -> AsyncIterable["_models.DevCenter"]: """Lists all devcenters in a resource group. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param top: The maximum number of resources to return from the operation. Example: '$top=10'. Default value is None. @@ -157,7 +172,9 @@ def list_by_resource_group( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevCenterListResult] error_map = { @@ -185,10 +202,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -223,7 +247,8 @@ async def get_next(next_link=None): async def get(self, resource_group_name: str, dev_center_name: str, **kwargs: Any) -> _models.DevCenter: """Gets a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -243,7 +268,9 @@ async def get(self, resource_group_name: str, dev_center_name: str, **kwargs: An _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevCenter] request = build_get_request( @@ -291,7 +318,9 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevCenter] @@ -353,7 +382,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.DevCenter]: """Creates or updates a devcenter resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -388,7 +418,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.DevCenter]: """Creates or updates a devcenter resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -417,7 +448,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.DevCenter]: """Creates or updates a devcenter resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -442,7 +474,9 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevCenter] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -502,7 +536,9 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DevCenter]] @@ -562,7 +598,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.DevCenter]: """Partially updates a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -597,7 +634,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.DevCenter]: """Partially updates a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -626,7 +664,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.DevCenter]: """Partially updates a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -651,7 +690,9 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevCenter] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -711,7 +752,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -745,7 +788,8 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements async def begin_delete(self, resource_group_name: str, dev_center_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -764,7 +808,9 @@ async def begin_delete(self, resource_group_name: str, dev_center_name: str, **k _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_environment_types_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_environment_types_operations.py index be331eca00a9..2e0363a511f6 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_environment_types_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_environment_types_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -36,6 +37,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +51,7 @@ class EnvironmentTypesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`environment_types` attribute. """ @@ -65,7 +70,8 @@ def list_by_dev_center( ) -> AsyncIterable["_models.EnvironmentType"]: """Lists environment types for the devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -80,7 +86,9 @@ def list_by_dev_center( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.EnvironmentTypeListResult] error_map = { @@ -109,10 +117,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -149,7 +164,8 @@ async def get( ) -> _models.EnvironmentType: """Gets an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -171,7 +187,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.EnvironmentType] request = build_get_request( @@ -219,7 +237,8 @@ async def create_or_update( ) -> _models.EnvironmentType: """Creates or updates an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -249,7 +268,8 @@ async def create_or_update( ) -> _models.EnvironmentType: """Creates or updates an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -277,7 +297,8 @@ async def create_or_update( ) -> _models.EnvironmentType: """Creates or updates an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -304,7 +325,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.EnvironmentType] @@ -364,7 +387,8 @@ async def update( ) -> _models.EnvironmentType: """Partially updates an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -394,7 +418,8 @@ async def update( ) -> _models.EnvironmentType: """Partially updates an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -422,7 +447,8 @@ async def update( ) -> _models.EnvironmentType: """Partially updates an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -450,7 +476,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.EnvironmentType] @@ -503,7 +531,8 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -525,7 +554,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_galleries_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_galleries_operations.py index 531e51480956..aa6b4a47b71c 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_galleries_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_galleries_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_list_by_dev_center_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +52,7 @@ class GalleriesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`galleries` attribute. """ @@ -66,7 +71,8 @@ def list_by_dev_center( ) -> AsyncIterable["_models.Gallery"]: """Lists galleries for a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -81,7 +87,9 @@ def list_by_dev_center( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryListResult] error_map = { @@ -110,10 +118,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -150,7 +165,8 @@ async def get( ) -> _models.Gallery: """Gets a gallery. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -172,7 +188,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -226,7 +244,9 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] @@ -286,7 +306,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Gallery]: """Creates or updates a gallery. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -324,7 +345,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Gallery]: """Creates or updates a gallery. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -360,7 +382,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Gallery]: """Creates or updates a gallery. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -387,7 +410,9 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -448,7 +473,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -485,7 +512,8 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Deletes a gallery resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -506,7 +534,9 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_image_versions_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_image_versions_operations.py index 40df2212ab31..b660239a2616 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_image_versions_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_image_versions_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._image_versions_operations import build_get_request, build_list_by_image_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ class ImageVersionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`image_versions` attribute. """ @@ -59,7 +64,8 @@ def list_by_image( ) -> AsyncIterable["_models.ImageVersion"]: """Lists versions for an image. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -75,7 +81,9 @@ def list_by_image( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ImageVersionListResult] error_map = { @@ -105,10 +113,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -151,7 +166,8 @@ async def get( ) -> _models.ImageVersion: """Gets an image version. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -177,7 +193,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ImageVersion] request = build_get_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_images_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_images_operations.py index bbb4675e65b2..0be80e46cb93 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_images_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_images_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -34,6 +35,10 @@ build_list_by_gallery_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +49,7 @@ class ImagesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`images` attribute. """ @@ -63,7 +68,8 @@ def list_by_dev_center( ) -> AsyncIterable["_models.Image"]: """Lists images for a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -78,7 +84,9 @@ def list_by_dev_center( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ImageListResult] error_map = { @@ -107,10 +115,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -152,7 +167,8 @@ def list_by_gallery( ) -> AsyncIterable["_models.Image"]: """Lists images for a gallery. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -169,7 +185,9 @@ def list_by_gallery( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ImageListResult] error_map = { @@ -199,10 +217,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -239,7 +264,8 @@ async def get( ) -> _models.Image: """Gets a gallery image. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -263,7 +289,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Image] request = build_get_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_network_connections_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_network_connections_operations.py index ffa053a7403f..a4995939b3d5 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_network_connections_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_network_connections_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -42,6 +43,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +57,7 @@ class NetworkConnectionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`network_connections` attribute. """ @@ -82,7 +87,9 @@ def list_by_subscription( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkConnectionListResult] error_map = { @@ -109,10 +116,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -149,7 +163,8 @@ def list_by_resource_group( ) -> AsyncIterable["_models.NetworkConnection"]: """Lists network connections in a resource group. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param top: The maximum number of resources to return from the operation. Example: '$top=10'. Default value is None. @@ -162,7 +177,9 @@ def list_by_resource_group( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkConnectionListResult] error_map = { @@ -190,10 +207,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -230,7 +254,8 @@ async def get( ) -> _models.NetworkConnection: """Gets a network connection resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -251,7 +276,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkConnection] request = build_get_request( @@ -303,7 +330,9 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkConnection] @@ -365,7 +394,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.NetworkConnection]: """Creates or updates a Network Connections resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -401,7 +431,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.NetworkConnection]: """Creates or updates a Network Connections resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -435,7 +466,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.NetworkConnection]: """Creates or updates a Network Connections resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -461,7 +493,9 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkConnection] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -525,7 +559,9 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.NetworkConnection]] @@ -585,7 +621,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.NetworkConnection]: """Partially updates a Network Connection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -621,7 +658,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.NetworkConnection]: """Partially updates a Network Connection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -655,7 +693,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.NetworkConnection]: """Partially updates a Network Connection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -681,7 +720,9 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkConnection] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -741,7 +782,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -777,7 +820,8 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Deletes a Network Connections resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -797,7 +841,9 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) @@ -844,7 +890,8 @@ def list_health_details( ) -> AsyncIterable["_models.HealthCheckStatusDetails"]: """Lists health check status details. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -862,7 +909,9 @@ def list_health_details( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthCheckStatusDetailsListResult] error_map = { @@ -891,10 +940,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -931,7 +987,8 @@ async def get_health_details( ) -> _models.HealthCheckStatusDetails: """Gets health check status details. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -952,7 +1009,9 @@ async def get_health_details( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthCheckStatusDetails] request = build_get_health_details_request( @@ -993,7 +1052,8 @@ async def run_health_checks( # pylint: disable=inconsistent-return-statements """Triggers a new health check run. The execution and health check result can be tracked via the network Connection health check details. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -1014,7 +1074,9 @@ async def run_health_checks( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_run_health_checks_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_operation_statuses_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_operation_statuses_operations.py index 5911326f5ba4..d7a0a74bfdcd 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_operation_statuses_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_operation_statuses_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._operation_statuses_operations import build_get_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -37,7 +42,7 @@ class OperationStatusesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`operation_statuses` attribute. """ @@ -76,7 +81,9 @@ async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models. _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatus] request = build_get_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_operations.py index 54ed2aeaf8dc..2ee56afd4275 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +44,7 @@ class Operations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`operations` attribute. """ @@ -64,7 +69,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { @@ -89,10 +96,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_pools_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_pools_operations.py index 07644a761007..4c04b5e675dc 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_pools_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_pools_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -38,6 +39,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +53,7 @@ class PoolsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`pools` attribute. """ @@ -67,7 +72,8 @@ def list_by_project( ) -> AsyncIterable["_models.Pool"]: """Lists pools for a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -82,7 +88,9 @@ def list_by_project( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.PoolListResult] error_map = { @@ -111,10 +119,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -149,7 +164,8 @@ async def get_next(next_link=None): async def get(self, resource_group_name: str, project_name: str, pool_name: str, **kwargs: Any) -> _models.Pool: """Gets a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -171,7 +187,9 @@ async def get(self, resource_group_name: str, project_name: str, pool_name: str, _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pool] request = build_get_request( @@ -220,7 +238,9 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pool] @@ -284,7 +304,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Pool]: """Creates or updates a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -321,7 +342,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Pool]: """Creates or updates a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -351,7 +373,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Pool]: """Creates or updates a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -377,7 +400,9 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pool] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -443,7 +468,9 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Pool]] @@ -505,7 +532,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.Pool]: """Partially updates a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -542,7 +570,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.Pool]: """Partially updates a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -577,7 +606,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.Pool]: """Partially updates a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -603,7 +633,9 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pool] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -664,7 +696,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -701,7 +735,8 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Deletes a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -722,7 +757,9 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_project_allowed_environment_types_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_project_allowed_environment_types_operations.py index 305345fa0cc4..57f865dec633 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_project_allowed_environment_types_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_project_allowed_environment_types_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._project_allowed_environment_types_operations import build_get_request, build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ class ProjectAllowedEnvironmentTypesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`project_allowed_environment_types` attribute. """ @@ -59,7 +64,8 @@ def list( ) -> AsyncIterable["_models.AllowedEnvironmentType"]: """Lists allowed environment types for a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -76,7 +82,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AllowedEnvironmentTypeListResult] error_map = { @@ -105,10 +113,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -145,7 +160,8 @@ async def get( ) -> _models.AllowedEnvironmentType: """Gets an allowed environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -167,7 +183,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AllowedEnvironmentType] request = build_get_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_project_environment_types_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_project_environment_types_operations.py index 261e6ac8b0d7..912679238982 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_project_environment_types_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_project_environment_types_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -36,6 +37,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +51,7 @@ class ProjectEnvironmentTypesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`project_environment_types` attribute. """ @@ -65,7 +70,8 @@ def list( ) -> AsyncIterable["_models.ProjectEnvironmentType"]: """Lists environment types for a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -82,7 +88,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ProjectEnvironmentTypeListResult] error_map = { @@ -111,10 +119,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -151,7 +166,8 @@ async def get( ) -> _models.ProjectEnvironmentType: """Gets a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -173,7 +189,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ProjectEnvironmentType] request = build_get_request( @@ -221,7 +239,8 @@ async def create_or_update( ) -> _models.ProjectEnvironmentType: """Creates or updates a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -251,7 +270,8 @@ async def create_or_update( ) -> _models.ProjectEnvironmentType: """Creates or updates a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -279,7 +299,8 @@ async def create_or_update( ) -> _models.ProjectEnvironmentType: """Creates or updates a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -307,7 +328,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.ProjectEnvironmentType] @@ -367,7 +390,8 @@ async def update( ) -> _models.ProjectEnvironmentType: """Partially updates a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -397,7 +421,8 @@ async def update( ) -> _models.ProjectEnvironmentType: """Partially updates a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -425,7 +450,8 @@ async def update( ) -> _models.ProjectEnvironmentType: """Partially updates a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -453,7 +479,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.ProjectEnvironmentType] @@ -506,7 +534,8 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -528,7 +557,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_projects_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_projects_operations.py index 4064e7195cb4..b096dca044f4 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_projects_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_projects_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -39,6 +40,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +54,7 @@ class ProjectsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`projects` attribute. """ @@ -77,7 +82,9 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ProjectListResult] error_map = { @@ -104,10 +111,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -144,7 +158,8 @@ def list_by_resource_group( ) -> AsyncIterable["_models.Project"]: """Lists all projects in the resource group. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param top: The maximum number of resources to return from the operation. Example: '$top=10'. Default value is None. @@ -157,7 +172,9 @@ def list_by_resource_group( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ProjectListResult] error_map = { @@ -185,10 +202,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -223,7 +247,8 @@ async def get_next(next_link=None): async def get(self, resource_group_name: str, project_name: str, **kwargs: Any) -> _models.Project: """Gets a specific project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -243,7 +268,9 @@ async def get(self, resource_group_name: str, project_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Project] request = build_get_request( @@ -291,7 +318,9 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Project] @@ -353,7 +382,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Project]: """Creates or updates a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -388,7 +418,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Project]: """Creates or updates a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -417,7 +448,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Project]: """Creates or updates a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -442,7 +474,9 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Project] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -502,7 +536,9 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Project]] @@ -562,7 +598,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.Project]: """Partially updates a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -597,7 +634,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.Project]: """Partially updates a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -626,7 +664,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.Project]: """Partially updates a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -651,7 +690,9 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Project] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -711,7 +752,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -745,7 +788,8 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements async def begin_delete(self, resource_group_name: str, project_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a project resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -764,7 +808,9 @@ async def begin_delete(self, resource_group_name: str, project_name: str, **kwar _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_schedules_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_schedules_operations.py index 5988b7d279df..06c2ca85b280 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_schedules_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_schedules_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -38,6 +39,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +53,7 @@ class SchedulesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`schedules` attribute. """ @@ -67,7 +72,8 @@ def list_by_pool( ) -> AsyncIterable["_models.Schedule"]: """Lists schedules for a pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -84,7 +90,9 @@ def list_by_pool( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduleListResult] error_map = { @@ -114,10 +122,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -160,7 +175,8 @@ async def get( ) -> _models.Schedule: """Gets a schedule resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -187,7 +203,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Schedule] request = build_get_request( @@ -245,7 +263,9 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Schedule] @@ -281,11 +301,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [201]: + 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) - deserialized = self._deserialize("Schedule", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("Schedule", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Schedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -309,7 +333,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Schedule]: """Creates or updates a Schedule. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -354,7 +379,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Schedule]: """Creates or updates a Schedule. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -397,7 +423,8 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Schedule]: """Creates or updates a Schedule. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -429,7 +456,9 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Schedule] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -478,7 +507,7 @@ def get_long_running_output(pipeline_response): begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}"} # type: ignore - async def _update_initial( # pylint: disable=inconsistent-return-statements + async def _update_initial( self, resource_group_name: str, project_name: str, @@ -487,7 +516,7 @@ async def _update_initial( # pylint: disable=inconsistent-return-statements body: Union[_models.ScheduleUpdate, IO], top: Optional[int] = None, **kwargs: Any - ) -> None: + ) -> Optional[_models.Schedule]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -499,9 +528,11 @@ async def _update_initial( # pylint: disable=inconsistent-return-statements _headers = case_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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Schedule]] content_type = content_type or "application/json" _json = None @@ -535,12 +566,18 @@ async def _update_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Schedule", pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + + return deserialized _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}"} # type: ignore @@ -556,10 +593,11 @@ async def begin_update( *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: + ) -> AsyncLROPoller[_models.Schedule]: """Partially updates a Scheduled. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -583,8 +621,9 @@ async def begin_update( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: 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] + :return: An instance of AsyncLROPoller that returns either Schedule or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.devcenter.models.Schedule] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -600,10 +639,11 @@ async def begin_update( *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: + ) -> AsyncLROPoller[_models.Schedule]: """Partially updates a Scheduled. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -627,8 +667,9 @@ async def begin_update( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: 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] + :return: An instance of AsyncLROPoller that returns either Schedule or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.devcenter.models.Schedule] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -642,10 +683,11 @@ async def begin_update( body: Union[_models.ScheduleUpdate, IO], top: Optional[int] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: + ) -> AsyncLROPoller[_models.Schedule]: """Partially updates a Scheduled. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -669,16 +711,19 @@ async def begin_update( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: 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] + :return: An instance of AsyncLROPoller that returns either Schedule or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.devcenter.models.Schedule] :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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Schedule] 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] @@ -699,9 +744,11 @@ async def begin_update( ) kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Schedule", pipeline_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + return deserialized if polling is True: polling_method = cast( @@ -743,7 +790,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -788,7 +837,8 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Deletes a Scheduled. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -814,7 +864,9 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_skus_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_skus_operations.py index afbb3dcea9e6..f2e5e7fdd964 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_skus_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_skus_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_operations import build_list_by_subscription_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +44,7 @@ class SkusOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`skus` attribute. """ @@ -67,7 +72,9 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SkuListResult] error_map = { @@ -94,10 +101,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_usages_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_usages_operations.py index f443c33adcf9..006495a547aa 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_usages_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/aio/operations/_usages_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +44,7 @@ class UsagesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.aio.DevCenterMgmtClient`'s :attr:`usages` attribute. """ @@ -66,7 +71,9 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ListUsagesResult] error_map = { @@ -93,10 +100,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/models/__init__.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/models/__init__.py index 3d26bc979be0..2cf7a57f6a1d 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/models/__init__.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/models/__init__.py @@ -30,6 +30,8 @@ from ._models_py3 import EnvironmentType from ._models_py3 import EnvironmentTypeListResult from ._models_py3 import EnvironmentTypeUpdate +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail from ._models_py3 import Gallery from ._models_py3 import GalleryListResult from ._models_py3 import GitCatalog @@ -53,7 +55,7 @@ from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult from ._models_py3 import OperationStatus -from ._models_py3 import OperationStatusError +from ._models_py3 import OperationStatusResult from ._models_py3 import Pool from ._models_py3 import PoolListResult from ._models_py3 import PoolProperties @@ -89,20 +91,21 @@ from ._models_py3 import UserAssignedIdentity from ._models_py3 import UserRoleAssignmentValue -from ._dev_center_client_enums import ActionType -from ._dev_center_client_enums import CreatedByType -from ._dev_center_client_enums import DomainJoinType -from ._dev_center_client_enums import EnableStatus -from ._dev_center_client_enums import HealthCheckStatus -from ._dev_center_client_enums import ImageValidationStatus -from ._dev_center_client_enums import LicenseType -from ._dev_center_client_enums import LocalAdminStatus -from ._dev_center_client_enums import ManagedServiceIdentityType -from ._dev_center_client_enums import Origin -from ._dev_center_client_enums import ScheduledFrequency -from ._dev_center_client_enums import ScheduledType -from ._dev_center_client_enums import SkuTier -from ._dev_center_client_enums import UsageUnit +from ._dev_center_mgmt_client_enums import ActionType +from ._dev_center_mgmt_client_enums import CatalogSyncState +from ._dev_center_mgmt_client_enums import CreatedByType +from ._dev_center_mgmt_client_enums import DomainJoinType +from ._dev_center_mgmt_client_enums import EnableStatus +from ._dev_center_mgmt_client_enums import HealthCheckStatus +from ._dev_center_mgmt_client_enums import ImageValidationStatus +from ._dev_center_mgmt_client_enums import LicenseType +from ._dev_center_mgmt_client_enums import LocalAdminStatus +from ._dev_center_mgmt_client_enums import ManagedServiceIdentityType +from ._dev_center_mgmt_client_enums import Origin +from ._dev_center_mgmt_client_enums import ScheduledFrequency +from ._dev_center_mgmt_client_enums import ScheduledType +from ._dev_center_mgmt_client_enums import SkuTier +from ._dev_center_mgmt_client_enums import UsageUnit 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 @@ -132,6 +135,8 @@ "EnvironmentType", "EnvironmentTypeListResult", "EnvironmentTypeUpdate", + "ErrorAdditionalInfo", + "ErrorDetail", "Gallery", "GalleryListResult", "GitCatalog", @@ -155,7 +160,7 @@ "OperationDisplay", "OperationListResult", "OperationStatus", - "OperationStatusError", + "OperationStatusResult", "Pool", "PoolListResult", "PoolProperties", @@ -191,6 +196,7 @@ "UserAssignedIdentity", "UserRoleAssignmentValue", "ActionType", + "CatalogSyncState", "CreatedByType", "DomainJoinType", "EnableStatus", diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/models/_dev_center_client_enums.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/models/_dev_center_mgmt_client_enums.py similarity index 93% rename from sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/models/_dev_center_client_enums.py rename to sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/models/_dev_center_mgmt_client_enums.py index e011cb3e3309..59f79ab427aa 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/models/_dev_center_client_enums.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/models/_dev_center_mgmt_client_enums.py @@ -16,6 +16,15 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): INTERNAL = "Internal" +class CatalogSyncState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The synchronization state of the catalog.""" + + SUCCEEDED = "Succeeded" + IN_PROGRESS = "InProgress" + FAILED = "Failed" + CANCELED = "Canceled" + + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource.""" diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/models/_models_py3.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/models/_models_py3.py index 082bd26e15d2..319a55c7e9d4 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/models/_models_py3.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/models/_models_py3.py @@ -273,6 +273,9 @@ class Catalog(Resource): :vartype ado_git: ~azure.mgmt.devcenter.models.GitCatalog :ivar provisioning_state: The provisioning state of the resource. :vartype provisioning_state: str + :ivar sync_state: The synchronization state of the catalog. Known values are: "Succeeded", + "InProgress", "Failed", and "Canceled". + :vartype sync_state: str or ~azure.mgmt.devcenter.models.CatalogSyncState :ivar last_sync_time: When the catalog was last synced. :vartype last_sync_time: ~datetime.datetime """ @@ -283,6 +286,7 @@ class Catalog(Resource): "type": {"readonly": True}, "system_data": {"readonly": True}, "provisioning_state": {"readonly": True}, + "sync_state": {"readonly": True}, "last_sync_time": {"readonly": True}, } @@ -294,6 +298,7 @@ class Catalog(Resource): "git_hub": {"key": "properties.gitHub", "type": "GitCatalog"}, "ado_git": {"key": "properties.adoGit", "type": "GitCatalog"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "sync_state": {"key": "properties.syncState", "type": "str"}, "last_sync_time": {"key": "properties.lastSyncTime", "type": "iso-8601"}, } @@ -314,6 +319,7 @@ def __init__( self.git_hub = git_hub self.ado_git = ado_git self.provisioning_state = None + self.sync_state = None self.last_sync_time = None @@ -388,12 +394,16 @@ class CatalogProperties(CatalogUpdateProperties): :vartype ado_git: ~azure.mgmt.devcenter.models.GitCatalog :ivar provisioning_state: The provisioning state of the resource. :vartype provisioning_state: str + :ivar sync_state: The synchronization state of the catalog. Known values are: "Succeeded", + "InProgress", "Failed", and "Canceled". + :vartype sync_state: str or ~azure.mgmt.devcenter.models.CatalogSyncState :ivar last_sync_time: When the catalog was last synced. :vartype last_sync_time: ~datetime.datetime """ _validation = { "provisioning_state": {"readonly": True}, + "sync_state": {"readonly": True}, "last_sync_time": {"readonly": True}, } @@ -401,6 +411,7 @@ class CatalogProperties(CatalogUpdateProperties): "git_hub": {"key": "gitHub", "type": "GitCatalog"}, "ado_git": {"key": "adoGit", "type": "GitCatalog"}, "provisioning_state": {"key": "provisioningState", "type": "str"}, + "sync_state": {"key": "syncState", "type": "str"}, "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, } @@ -419,6 +430,7 @@ def __init__( """ super().__init__(git_hub=git_hub, ado_git=ado_git, **kwargs) self.provisioning_state = None + self.sync_state = None self.last_sync_time = None @@ -1305,6 +1317,77 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): self.tags = tags +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.devcenter.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.devcenter.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + class Gallery(Resource): """Represents a gallery. @@ -2460,92 +2543,180 @@ def __init__(self, **kwargs): self.next_link = None -class OperationStatus(_serialization.Model): +class OperationStatusResult(_serialization.Model): """The current status of an async operation. - 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 ID for the operation status. + :ivar id: Fully qualified ID for the async operation. :vartype id: str - :ivar name: The operation id name. + :ivar name: Name of the async operation. :vartype name: str - :ivar status: Provisioning state of the resource. + :ivar status: Operation status. Required. :vartype status: str + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float :ivar start_time: The start time of the operation. :vartype start_time: ~datetime.datetime :ivar end_time: The end time of the operation. :vartype end_time: ~datetime.datetime - :ivar percent_complete: Percent of the operation that is complete. - :vartype percent_complete: float - :ivar properties: Custom operation properties, populated only for a successful operation. - :vartype properties: JSON - :ivar error: Operation Error message. - :vartype error: ~azure.mgmt.devcenter.models.OperationStatusError + :ivar operations: The operations list. + :vartype operations: list[~azure.mgmt.devcenter.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.devcenter.models.ErrorDetail """ _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "status": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - "percent_complete": {"readonly": True, "maximum": 100, "minimum": 0}, - "properties": {"readonly": True}, + "status": {"required": True}, + "percent_complete": {"maximum": 100, "minimum": 0}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "status": {"key": "status", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "float"}, "start_time": {"key": "startTime", "type": "iso-8601"}, "end_time": {"key": "endTime", "type": "iso-8601"}, - "percent_complete": {"key": "percentComplete", "type": "float"}, - "properties": {"key": "properties", "type": "object"}, - "error": {"key": "error", "type": "OperationStatusError"}, + "operations": {"key": "operations", "type": "[OperationStatusResult]"}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__(self, *, error: Optional["_models.OperationStatusError"] = None, **kwargs): + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + percent_complete: Optional[float] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + operations: Optional[List["_models.OperationStatusResult"]] = None, + error: Optional["_models.ErrorDetail"] = None, + **kwargs + ): """ - :keyword error: Operation Error message. - :paramtype error: ~azure.mgmt.devcenter.models.OperationStatusError + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: Operation status. Required. + :paramtype status: str + :keyword percent_complete: Percent of the operation that is complete. + :paramtype percent_complete: float + :keyword start_time: The start time of the operation. + :paramtype start_time: ~datetime.datetime + :keyword end_time: The end time of the operation. + :paramtype end_time: ~datetime.datetime + :keyword operations: The operations list. + :paramtype operations: list[~azure.mgmt.devcenter.models.OperationStatusResult] + :keyword error: If present, details of the operation error. + :paramtype error: ~azure.mgmt.devcenter.models.ErrorDetail """ super().__init__(**kwargs) - self.id = None - self.name = None - self.status = None - self.start_time = None - self.end_time = None - self.percent_complete = None - self.properties = None + self.id = id + self.name = name + self.status = status + self.percent_complete = percent_complete + self.start_time = start_time + self.end_time = end_time + self.operations = operations self.error = error -class OperationStatusError(_serialization.Model): - """Operation Error message. +class OperationStatus(OperationStatusResult): + """The current status of an async operation. Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified ID for the async operation. + :vartype id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar operations: The operations list. + :vartype operations: list[~azure.mgmt.devcenter.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.devcenter.models.ErrorDetail + :ivar resource_id: The id of the resource. + :vartype resource_id: str + :ivar properties: Custom operation properties, populated only for a successful operation. + :vartype properties: JSON """ _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, + "status": {"required": True}, + "percent_complete": {"maximum": 100, "minimum": 0}, + "resource_id": {"readonly": True}, + "properties": {"readonly": True}, } _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "float"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "operations": {"key": "operations", "type": "[OperationStatusResult]"}, + "error": {"key": "error", "type": "ErrorDetail"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "properties": {"key": "properties", "type": "object"}, } - def __init__(self, **kwargs): - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + percent_complete: Optional[float] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + operations: Optional[List["_models.OperationStatusResult"]] = None, + error: Optional["_models.ErrorDetail"] = None, + **kwargs + ): + """ + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: Operation status. Required. + :paramtype status: str + :keyword percent_complete: Percent of the operation that is complete. + :paramtype percent_complete: float + :keyword start_time: The start time of the operation. + :paramtype start_time: ~datetime.datetime + :keyword end_time: The end time of the operation. + :paramtype end_time: ~datetime.datetime + :keyword operations: The operations list. + :paramtype operations: list[~azure.mgmt.devcenter.models.OperationStatusResult] + :keyword error: If present, details of the operation error. + :paramtype error: ~azure.mgmt.devcenter.models.ErrorDetail + """ + super().__init__( + id=id, + name=name, + status=status, + percent_complete=percent_complete, + start_time=start_time, + end_time=end_time, + operations=operations, + error=error, + **kwargs + ) + self.resource_id = None + self.properties = None class Pool(TrackedResource): # pylint: disable=too-many-instance-attributes diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_attached_networks_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_attached_networks_operations.py index bdf9d52a2267..844da0b50b6f 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_attached_networks_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_attached_networks_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +49,9 @@ def build_list_by_project_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -53,8 +60,10 @@ def build_list_by_project_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/attachednetworks", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), } @@ -81,7 +90,9 @@ def build_get_by_project_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,8 +101,10 @@ def build_get_by_project_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/attachednetworks/{attachedNetworkConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "attachedNetworkConnectionName": _SERIALIZER.url( "attached_network_connection_name", attached_network_connection_name, "str" @@ -115,7 +128,9 @@ def build_list_by_dev_center_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,8 +139,10 @@ def build_list_by_dev_center_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/attachednetworks", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), } @@ -152,7 +169,9 @@ def build_get_by_dev_center_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,8 +180,10 @@ def build_get_by_dev_center_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/attachednetworks/{attachedNetworkConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "attachedNetworkConnectionName": _SERIALIZER.url( "attached_network_connection_name", attached_network_connection_name, "str" @@ -190,7 +211,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -200,8 +223,10 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/attachednetworks/{attachedNetworkConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "attachedNetworkConnectionName": _SERIALIZER.url( "attached_network_connection_name", attached_network_connection_name, "str" @@ -231,7 +256,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -240,8 +267,10 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/attachednetworks/{attachedNetworkConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "attachedNetworkConnectionName": _SERIALIZER.url( "attached_network_connection_name", attached_network_connection_name, "str" @@ -265,7 +294,7 @@ class AttachedNetworksOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`attached_networks` attribute. """ @@ -284,7 +313,8 @@ def list_by_project( ) -> Iterable["_models.AttachedNetworkConnection"]: """Lists the attached NetworkConnections for a Project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -300,7 +330,9 @@ def list_by_project( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedNetworkListResult] error_map = { @@ -329,10 +361,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -369,7 +408,8 @@ def get_by_project( ) -> _models.AttachedNetworkConnection: """Gets an attached NetworkConnection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -391,7 +431,9 @@ def get_by_project( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedNetworkConnection] request = build_get_by_project_request( @@ -432,7 +474,8 @@ def list_by_dev_center( ) -> Iterable["_models.AttachedNetworkConnection"]: """Lists the attached NetworkConnections for a DevCenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -448,7 +491,9 @@ def list_by_dev_center( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedNetworkListResult] error_map = { @@ -477,10 +522,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -517,7 +569,8 @@ def get_by_dev_center( ) -> _models.AttachedNetworkConnection: """Gets an attached NetworkConnection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -539,7 +592,9 @@ def get_by_dev_center( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedNetworkConnection] request = build_get_by_dev_center_request( @@ -593,7 +648,9 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedNetworkConnection] @@ -653,7 +710,8 @@ def begin_create_or_update( ) -> LROPoller[_models.AttachedNetworkConnection]: """Creates or updates an attached NetworkConnection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -691,7 +749,8 @@ def begin_create_or_update( ) -> LROPoller[_models.AttachedNetworkConnection]: """Creates or updates an attached NetworkConnection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -727,7 +786,8 @@ def begin_create_or_update( ) -> LROPoller[_models.AttachedNetworkConnection]: """Creates or updates an attached NetworkConnection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -755,7 +815,9 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedNetworkConnection] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -815,7 +877,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -852,7 +916,8 @@ def begin_delete( ) -> LROPoller[None]: """Un-attach a NetworkConnection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -873,7 +938,9 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_catalogs_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_catalogs_operations.py index bab4921598da..627eef9971e9 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_catalogs_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_catalogs_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +49,9 @@ def build_list_by_dev_center_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -53,8 +60,10 @@ def build_list_by_dev_center_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), } @@ -77,7 +86,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -86,8 +97,10 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "catalogName": _SERIALIZER.url("catalog_name", catalog_name, "str"), } @@ -109,7 +122,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -119,8 +134,10 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "catalogName": _SERIALIZER.url("catalog_name", catalog_name, "str"), } @@ -144,7 +161,9 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -154,8 +173,10 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "catalogName": _SERIALIZER.url("catalog_name", catalog_name, "str"), } @@ -179,7 +200,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,8 +211,10 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "catalogName": _SERIALIZER.url("catalog_name", catalog_name, "str"), } @@ -211,7 +236,9 @@ def build_sync_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -220,8 +247,10 @@ def build_sync_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}/sync", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "catalogName": _SERIALIZER.url("catalog_name", catalog_name, "str"), } @@ -243,7 +272,7 @@ class CatalogsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`catalogs` attribute. """ @@ -262,7 +291,8 @@ def list_by_dev_center( ) -> Iterable["_models.Catalog"]: """Lists catalogs for a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -277,7 +307,9 @@ def list_by_dev_center( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.CatalogListResult] error_map = { @@ -306,10 +338,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -344,7 +383,8 @@ def get_next(next_link=None): def get(self, resource_group_name: str, dev_center_name: str, catalog_name: str, **kwargs: Any) -> _models.Catalog: """Gets a catalog. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -366,7 +406,9 @@ def get(self, resource_group_name: str, dev_center_name: str, catalog_name: str, _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Catalog] request = build_get_request( @@ -420,7 +462,9 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Catalog] @@ -480,7 +524,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Catalog]: """Creates or updates a catalog. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -517,7 +562,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Catalog]: """Creates or updates a catalog. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -552,7 +598,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Catalog]: """Creates or updates a catalog. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -578,7 +625,9 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Catalog] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -643,7 +692,9 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Catalog]] @@ -705,7 +756,8 @@ def begin_update( ) -> LROPoller[_models.Catalog]: """Partially updates a catalog. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -742,7 +794,8 @@ def begin_update( ) -> LROPoller[_models.Catalog]: """Partially updates a catalog. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -777,7 +830,8 @@ def begin_update( ) -> LROPoller[_models.Catalog]: """Partially updates a catalog. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -803,7 +857,9 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Catalog] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -863,7 +919,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -900,7 +958,8 @@ def begin_delete( ) -> LROPoller[None]: """Deletes a catalog resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -921,7 +980,9 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) @@ -976,7 +1037,9 @@ def _sync_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_sync_request( @@ -1013,7 +1076,8 @@ def begin_sync( ) -> LROPoller[None]: """Syncs templates for a template source. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -1034,7 +1098,9 @@ def begin_sync( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) @@ -1058,7 +1124,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- if polling is True: polling_method = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) ) # type: PollingMethod elif polling is False: polling_method = cast(PollingMethod, NoPolling()) diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_dev_box_definitions_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_dev_box_definitions_operations.py index 7373f0611710..d7199c19032a 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_dev_box_definitions_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_dev_box_definitions_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +49,9 @@ def build_list_by_dev_center_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -53,8 +60,10 @@ def build_list_by_dev_center_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/devboxdefinitions", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), } @@ -77,7 +86,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -86,8 +97,10 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/devboxdefinitions/{devBoxDefinitionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "devBoxDefinitionName": _SERIALIZER.url("dev_box_definition_name", dev_box_definition_name, "str"), } @@ -109,7 +122,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -119,8 +134,10 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/devboxdefinitions/{devBoxDefinitionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "devBoxDefinitionName": _SERIALIZER.url("dev_box_definition_name", dev_box_definition_name, "str"), } @@ -144,7 +161,9 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -154,8 +173,10 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/devboxdefinitions/{devBoxDefinitionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "devBoxDefinitionName": _SERIALIZER.url("dev_box_definition_name", dev_box_definition_name, "str"), } @@ -179,7 +200,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,8 +211,10 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/devboxdefinitions/{devBoxDefinitionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "devBoxDefinitionName": _SERIALIZER.url("dev_box_definition_name", dev_box_definition_name, "str"), } @@ -211,7 +236,9 @@ def build_list_by_project_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -220,8 +247,10 @@ def build_list_by_project_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/devboxdefinitions", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), } @@ -244,7 +273,9 @@ def build_get_by_project_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -253,8 +284,10 @@ def build_get_by_project_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/devboxdefinitions/{devBoxDefinitionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "devBoxDefinitionName": _SERIALIZER.url("dev_box_definition_name", dev_box_definition_name, "str"), } @@ -276,7 +309,7 @@ class DevBoxDefinitionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`dev_box_definitions` attribute. """ @@ -295,7 +328,8 @@ def list_by_dev_center( ) -> Iterable["_models.DevBoxDefinition"]: """List Dev Box definitions for a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -310,7 +344,9 @@ def list_by_dev_center( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevBoxDefinitionListResult] error_map = { @@ -339,10 +375,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -379,7 +422,8 @@ def get( ) -> _models.DevBoxDefinition: """Gets a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -401,7 +445,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevBoxDefinition] request = build_get_request( @@ -455,7 +501,9 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevBoxDefinition] @@ -519,7 +567,8 @@ def begin_create_or_update( ) -> LROPoller[_models.DevBoxDefinition]: """Creates or updates a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -557,7 +606,8 @@ def begin_create_or_update( ) -> LROPoller[_models.DevBoxDefinition]: """Creates or updates a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -593,7 +643,8 @@ def begin_create_or_update( ) -> LROPoller[_models.DevBoxDefinition]: """Creates or updates a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -620,7 +671,9 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevBoxDefinition] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -685,7 +738,9 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DevBoxDefinition]] @@ -747,7 +802,8 @@ def begin_update( ) -> LROPoller[_models.DevBoxDefinition]: """Partially updates a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -785,7 +841,8 @@ def begin_update( ) -> LROPoller[_models.DevBoxDefinition]: """Partially updates a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -821,7 +878,8 @@ def begin_update( ) -> LROPoller[_models.DevBoxDefinition]: """Partially updates a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -848,7 +906,9 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevBoxDefinition] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -908,7 +968,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -945,7 +1007,8 @@ def begin_delete( ) -> LROPoller[None]: """Deletes a Dev Box definition. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -966,7 +1029,9 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) @@ -1013,7 +1078,8 @@ def list_by_project( ) -> Iterable["_models.DevBoxDefinition"]: """List Dev Box definitions configured for a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -1028,7 +1094,9 @@ def list_by_project( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevBoxDefinitionListResult] error_map = { @@ -1057,10 +1125,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1097,7 +1172,8 @@ def get_by_project( ) -> _models.DevBoxDefinition: """Gets a Dev Box definition configured for a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -1119,7 +1195,9 @@ def get_by_project( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevBoxDefinition] request = build_get_by_project_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_dev_centers_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_dev_centers_operations.py index 34fe32eb96b1..77f114b65f60 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_dev_centers_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_dev_centers_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,13 +49,15 @@ def build_list_by_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DevCenter/devcenters") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) @@ -72,7 +79,9 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,8 +90,10 @@ def build_list_by_resource_group_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", 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) @@ -104,7 +115,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -113,8 +126,10 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), } @@ -135,7 +150,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -145,8 +162,10 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), } @@ -169,7 +188,9 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -179,8 +200,10 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), } @@ -203,7 +226,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -212,8 +237,10 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), } @@ -234,7 +261,7 @@ class DevCentersOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`dev_centers` attribute. """ @@ -262,7 +289,9 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevCenterListResult] error_map = { @@ -289,10 +318,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -329,7 +365,8 @@ def list_by_resource_group( ) -> Iterable["_models.DevCenter"]: """Lists all devcenters in a resource group. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param top: The maximum number of resources to return from the operation. Example: '$top=10'. Default value is None. @@ -342,7 +379,9 @@ def list_by_resource_group( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevCenterListResult] error_map = { @@ -370,10 +409,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -408,7 +454,8 @@ def get_next(next_link=None): def get(self, resource_group_name: str, dev_center_name: str, **kwargs: Any) -> _models.DevCenter: """Gets a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -428,7 +475,9 @@ def get(self, resource_group_name: str, dev_center_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevCenter] request = build_get_request( @@ -476,7 +525,9 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevCenter] @@ -538,7 +589,8 @@ def begin_create_or_update( ) -> LROPoller[_models.DevCenter]: """Creates or updates a devcenter resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -572,7 +624,8 @@ def begin_create_or_update( ) -> LROPoller[_models.DevCenter]: """Creates or updates a devcenter resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -600,7 +653,8 @@ def begin_create_or_update( ) -> LROPoller[_models.DevCenter]: """Creates or updates a devcenter resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -624,7 +678,9 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevCenter] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -683,7 +739,9 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DevCenter]] @@ -743,7 +801,8 @@ def begin_update( ) -> LROPoller[_models.DevCenter]: """Partially updates a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -777,7 +836,8 @@ def begin_update( ) -> LROPoller[_models.DevCenter]: """Partially updates a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -805,7 +865,8 @@ def begin_update( ) -> LROPoller[_models.DevCenter]: """Partially updates a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -829,7 +890,9 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.DevCenter] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -888,7 +951,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -922,7 +987,8 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements def begin_delete(self, resource_group_name: str, dev_center_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -941,7 +1007,9 @@ def begin_delete(self, resource_group_name: str, dev_center_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_environment_types_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_environment_types_operations.py index 7e00aeb953f5..9f1ecba0fd02 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_environment_types_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_environment_types_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,9 @@ def build_list_by_dev_center_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -51,8 +58,10 @@ def build_list_by_dev_center_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/environmentTypes", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), } @@ -75,7 +84,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,8 +95,10 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/environmentTypes/{environmentTypeName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "environmentTypeName": _SERIALIZER.url("environment_type_name", environment_type_name, "str"), } @@ -107,7 +120,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -117,8 +132,10 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/environmentTypes/{environmentTypeName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "environmentTypeName": _SERIALIZER.url("environment_type_name", environment_type_name, "str"), } @@ -142,7 +159,9 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -152,8 +171,10 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/environmentTypes/{environmentTypeName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "environmentTypeName": _SERIALIZER.url("environment_type_name", environment_type_name, "str"), } @@ -177,7 +198,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,8 +209,10 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/environmentTypes/{environmentTypeName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "environmentTypeName": _SERIALIZER.url("environment_type_name", environment_type_name, "str"), } @@ -209,7 +234,7 @@ class EnvironmentTypesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`environment_types` attribute. """ @@ -228,7 +253,8 @@ def list_by_dev_center( ) -> Iterable["_models.EnvironmentType"]: """Lists environment types for the devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -243,7 +269,9 @@ def list_by_dev_center( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.EnvironmentTypeListResult] error_map = { @@ -272,10 +300,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -312,7 +347,8 @@ def get( ) -> _models.EnvironmentType: """Gets an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -334,7 +370,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.EnvironmentType] request = build_get_request( @@ -382,7 +420,8 @@ def create_or_update( ) -> _models.EnvironmentType: """Creates or updates an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -412,7 +451,8 @@ def create_or_update( ) -> _models.EnvironmentType: """Creates or updates an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -440,7 +480,8 @@ def create_or_update( ) -> _models.EnvironmentType: """Creates or updates an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -467,7 +508,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.EnvironmentType] @@ -527,7 +570,8 @@ def update( ) -> _models.EnvironmentType: """Partially updates an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -557,7 +601,8 @@ def update( ) -> _models.EnvironmentType: """Partially updates an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -585,7 +630,8 @@ def update( ) -> _models.EnvironmentType: """Partially updates an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -613,7 +659,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.EnvironmentType] @@ -666,7 +714,8 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -688,7 +737,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_galleries_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_galleries_operations.py index 209bec51fd03..14afe830e2ac 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_galleries_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_galleries_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +49,9 @@ def build_list_by_dev_center_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -53,8 +60,10 @@ def build_list_by_dev_center_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), } @@ -77,7 +86,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -86,8 +97,10 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries/{galleryName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), } @@ -109,7 +122,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -119,8 +134,10 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries/{galleryName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), } @@ -144,7 +161,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -153,8 +172,10 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries/{galleryName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), } @@ -176,7 +197,7 @@ class GalleriesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`galleries` attribute. """ @@ -195,7 +216,8 @@ def list_by_dev_center( ) -> Iterable["_models.Gallery"]: """Lists galleries for a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -210,7 +232,9 @@ def list_by_dev_center( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryListResult] error_map = { @@ -239,10 +263,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -277,7 +308,8 @@ def get_next(next_link=None): def get(self, resource_group_name: str, dev_center_name: str, gallery_name: str, **kwargs: Any) -> _models.Gallery: """Gets a gallery. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -299,7 +331,9 @@ def get(self, resource_group_name: str, dev_center_name: str, gallery_name: str, _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -353,7 +387,9 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] @@ -413,7 +449,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Gallery]: """Creates or updates a gallery. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -450,7 +487,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Gallery]: """Creates or updates a gallery. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -485,7 +523,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Gallery]: """Creates or updates a gallery. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -511,7 +550,9 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -571,7 +612,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -608,7 +651,8 @@ def begin_delete( ) -> LROPoller[None]: """Deletes a gallery resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -629,7 +673,9 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_image_versions_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_image_versions_operations.py index 5f95a1a2f6d5..8a749cef0b0b 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_image_versions_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_image_versions_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +52,9 @@ def build_list_by_image_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -56,8 +63,10 @@ def build_list_by_image_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries/{galleryName}/images/{imageName}/versions", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "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 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), "imageName": _SERIALIZER.url("image_name", image_name, "str"), @@ -86,7 +95,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -95,8 +106,10 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries/{galleryName}/images/{imageName}/versions/{versionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), "imageName": _SERIALIZER.url("image_name", image_name, "str"), @@ -120,7 +133,7 @@ class ImageVersionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`image_versions` attribute. """ @@ -139,7 +152,8 @@ def list_by_image( ) -> Iterable["_models.ImageVersion"]: """Lists versions for an image. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -155,7 +169,9 @@ def list_by_image( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ImageVersionListResult] error_map = { @@ -185,10 +201,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -231,7 +254,8 @@ def get( ) -> _models.ImageVersion: """Gets an image version. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -257,7 +281,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ImageVersion] request = build_get_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_images_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_images_operations.py index 85e652844992..7273d03d6afc 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_images_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_images_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,9 @@ def build_list_by_dev_center_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -51,8 +58,10 @@ def build_list_by_dev_center_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/images", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), } @@ -81,7 +90,9 @@ def build_list_by_gallery_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,8 +101,10 @@ def build_list_by_gallery_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries/{galleryName}/images", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), } @@ -120,7 +133,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,8 +144,10 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries/{galleryName}/images/{imageName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "devCenterName": _SERIALIZER.url("dev_center_name", dev_center_name, "str"), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), "imageName": _SERIALIZER.url("image_name", image_name, "str"), @@ -153,7 +170,7 @@ class ImagesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`images` attribute. """ @@ -172,7 +189,8 @@ def list_by_dev_center( ) -> Iterable["_models.Image"]: """Lists images for a devcenter. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -187,7 +205,9 @@ def list_by_dev_center( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ImageListResult] error_map = { @@ -216,10 +236,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -261,7 +288,8 @@ def list_by_gallery( ) -> Iterable["_models.Image"]: """Lists images for a gallery. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -278,7 +306,9 @@ def list_by_gallery( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ImageListResult] error_map = { @@ -308,10 +338,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -348,7 +385,8 @@ def get( ) -> _models.Image: """Gets a gallery image. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dev_center_name: The name of the devcenter. Required. :type dev_center_name: str @@ -372,7 +410,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Image] request = build_get_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_network_connections_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_network_connections_operations.py index 8bc4e25f5faf..db37739985a7 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_network_connections_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_network_connections_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +49,9 @@ def build_list_by_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,7 +59,7 @@ def build_list_by_subscription_request( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DevCenter/networkConnections" ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) @@ -74,7 +81,9 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -83,8 +92,10 @@ def build_list_by_resource_group_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", 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) @@ -106,7 +117,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -115,8 +128,10 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections/{networkConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "networkConnectionName": _SERIALIZER.url("network_connection_name", network_connection_name, "str"), } @@ -137,7 +152,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -147,8 +164,10 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections/{networkConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "networkConnectionName": _SERIALIZER.url("network_connection_name", network_connection_name, "str"), } @@ -171,7 +190,9 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -181,8 +202,10 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections/{networkConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "networkConnectionName": _SERIALIZER.url("network_connection_name", network_connection_name, "str"), } @@ -205,7 +228,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -214,8 +239,10 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections/{networkConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "networkConnectionName": _SERIALIZER.url("network_connection_name", network_connection_name, "str"), } @@ -241,7 +268,9 @@ def build_list_health_details_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -250,8 +279,10 @@ def build_list_health_details_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections/{networkConnectionName}/healthChecks", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "networkConnectionName": _SERIALIZER.url("network_connection_name", network_connection_name, "str"), } @@ -274,7 +305,9 @@ def build_get_health_details_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -283,8 +316,10 @@ def build_get_health_details_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections/{networkConnectionName}/healthChecks/latest", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "networkConnectionName": _SERIALIZER.url("network_connection_name", network_connection_name, "str"), } @@ -305,7 +340,9 @@ def build_run_health_checks_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -314,8 +351,10 @@ def build_run_health_checks_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections/{networkConnectionName}/runHealthChecks", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "networkConnectionName": _SERIALIZER.url("network_connection_name", network_connection_name, "str"), } @@ -336,7 +375,7 @@ class NetworkConnectionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`network_connections` attribute. """ @@ -364,7 +403,9 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkConnectionListResult] error_map = { @@ -391,10 +432,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -431,7 +479,8 @@ def list_by_resource_group( ) -> Iterable["_models.NetworkConnection"]: """Lists network connections in a resource group. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param top: The maximum number of resources to return from the operation. Example: '$top=10'. Default value is None. @@ -444,7 +493,9 @@ def list_by_resource_group( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkConnectionListResult] error_map = { @@ -472,10 +523,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -510,7 +568,8 @@ def get_next(next_link=None): def get(self, resource_group_name: str, network_connection_name: str, **kwargs: Any) -> _models.NetworkConnection: """Gets a network connection resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -531,7 +590,9 @@ def get(self, resource_group_name: str, network_connection_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkConnection] request = build_get_request( @@ -583,7 +644,9 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkConnection] @@ -645,7 +708,8 @@ def begin_create_or_update( ) -> LROPoller[_models.NetworkConnection]: """Creates or updates a Network Connections resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -681,7 +745,8 @@ def begin_create_or_update( ) -> LROPoller[_models.NetworkConnection]: """Creates or updates a Network Connections resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -715,7 +780,8 @@ def begin_create_or_update( ) -> LROPoller[_models.NetworkConnection]: """Creates or updates a Network Connections resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -741,7 +807,9 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkConnection] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -804,7 +872,9 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.NetworkConnection]] @@ -864,7 +934,8 @@ def begin_update( ) -> LROPoller[_models.NetworkConnection]: """Partially updates a Network Connection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -900,7 +971,8 @@ def begin_update( ) -> LROPoller[_models.NetworkConnection]: """Partially updates a Network Connection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -934,7 +1006,8 @@ def begin_update( ) -> LROPoller[_models.NetworkConnection]: """Partially updates a Network Connection. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -960,7 +1033,9 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkConnection] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -1019,7 +1094,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -1053,7 +1130,8 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements def begin_delete(self, resource_group_name: str, network_connection_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a Network Connections resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -1073,7 +1151,9 @@ def begin_delete(self, resource_group_name: str, network_connection_name: str, * _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) @@ -1119,7 +1199,8 @@ def list_health_details( ) -> Iterable["_models.HealthCheckStatusDetails"]: """Lists health check status details. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -1136,7 +1217,9 @@ def list_health_details( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthCheckStatusDetailsListResult] error_map = { @@ -1165,10 +1248,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1205,7 +1295,8 @@ def get_health_details( ) -> _models.HealthCheckStatusDetails: """Gets health check status details. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -1226,7 +1317,9 @@ def get_health_details( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthCheckStatusDetails] request = build_get_health_details_request( @@ -1267,7 +1360,8 @@ def run_health_checks( # pylint: disable=inconsistent-return-statements """Triggers a new health check run. The execution and health check result can be tracked via the network Connection health check details. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param network_connection_name: Name of the Network Connection that can be applied to a Pool. Required. @@ -1288,7 +1382,9 @@ def run_health_checks( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_run_health_checks_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_operation_statuses_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_operation_statuses_operations.py index a5c2cb34282e..6d1c49c05405 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_operation_statuses_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_operation_statuses_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,9 @@ def build_get_request(location: str, operation_id: str, subscription_id: str, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -47,7 +54,7 @@ def build_get_request(location: str, operation_id: str, subscription_id: str, ** "/subscriptions/{subscriptionId}/providers/Microsoft.DevCenter/locations/{location}/operationStatuses/{operationId}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "location": _SERIALIZER.url("location", location, "str"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } @@ -69,7 +76,7 @@ class OperationStatusesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`operation_statuses` attribute. """ @@ -108,7 +115,9 @@ def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.Operat _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatus] request = build_get_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_operations.py index a136d8e1c2ba..2cd568815552 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from .._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ 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-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +68,7 @@ class Operations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`operations` attribute. """ @@ -86,7 +93,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { @@ -111,10 +120,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_pools_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_pools_operations.py index 3e6c8de9a0f8..a5507e1ac917 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_pools_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_pools_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +49,9 @@ def build_list_by_project_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -53,8 +60,10 @@ def build_list_by_project_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), } @@ -77,7 +86,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -86,8 +97,10 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "poolName": _SERIALIZER.url("pool_name", pool_name, "str"), } @@ -109,7 +122,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -119,8 +134,10 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "poolName": _SERIALIZER.url("pool_name", pool_name, "str"), } @@ -144,7 +161,9 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -154,8 +173,10 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "poolName": _SERIALIZER.url("pool_name", pool_name, "str"), } @@ -179,7 +200,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,8 +211,10 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "poolName": _SERIALIZER.url("pool_name", pool_name, "str"), } @@ -211,7 +236,7 @@ class PoolsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`pools` attribute. """ @@ -230,7 +255,8 @@ def list_by_project( ) -> Iterable["_models.Pool"]: """Lists pools for a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -245,7 +271,9 @@ def list_by_project( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.PoolListResult] error_map = { @@ -274,10 +302,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -312,7 +347,8 @@ def get_next(next_link=None): def get(self, resource_group_name: str, project_name: str, pool_name: str, **kwargs: Any) -> _models.Pool: """Gets a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -334,7 +370,9 @@ def get(self, resource_group_name: str, project_name: str, pool_name: str, **kwa _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pool] request = build_get_request( @@ -383,7 +421,9 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pool] @@ -447,7 +487,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Pool]: """Creates or updates a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -484,7 +525,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Pool]: """Creates or updates a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -514,7 +556,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Pool]: """Creates or updates a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -540,7 +583,9 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pool] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -605,7 +650,9 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Pool]] @@ -667,7 +714,8 @@ def begin_update( ) -> LROPoller[_models.Pool]: """Partially updates a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -704,7 +752,8 @@ def begin_update( ) -> LROPoller[_models.Pool]: """Partially updates a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -739,7 +788,8 @@ def begin_update( ) -> LROPoller[_models.Pool]: """Partially updates a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -765,7 +815,9 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pool] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -825,7 +877,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -862,7 +916,8 @@ def begin_delete( ) -> LROPoller[None]: """Deletes a machine pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -883,7 +938,9 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_project_allowed_environment_types_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_project_allowed_environment_types_operations.py index ab2749ae632e..56ff0742e3e6 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_project_allowed_environment_types_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_project_allowed_environment_types_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,9 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -51,8 +58,10 @@ def build_list_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/allowedEnvironmentTypes", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), } @@ -75,7 +84,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,8 +95,10 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/allowedEnvironmentTypes/{environmentTypeName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "environmentTypeName": _SERIALIZER.url("environment_type_name", environment_type_name, "str"), } @@ -107,7 +120,7 @@ class ProjectAllowedEnvironmentTypesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`project_allowed_environment_types` attribute. """ @@ -126,7 +139,8 @@ def list( ) -> Iterable["_models.AllowedEnvironmentType"]: """Lists allowed environment types for a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -142,7 +156,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AllowedEnvironmentTypeListResult] error_map = { @@ -171,10 +187,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -211,7 +234,8 @@ def get( ) -> _models.AllowedEnvironmentType: """Gets an allowed environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -233,7 +257,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AllowedEnvironmentType] request = build_get_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_project_environment_types_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_project_environment_types_operations.py index 49ca782f5f63..4303f7472c41 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_project_environment_types_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_project_environment_types_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,9 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -51,8 +58,10 @@ def build_list_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/environmentTypes", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), } @@ -75,7 +84,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,8 +95,10 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/environmentTypes/{environmentTypeName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "environmentTypeName": _SERIALIZER.url("environment_type_name", environment_type_name, "str"), } @@ -107,7 +120,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -117,8 +132,10 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/environmentTypes/{environmentTypeName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "environmentTypeName": _SERIALIZER.url("environment_type_name", environment_type_name, "str"), } @@ -142,7 +159,9 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -152,8 +171,10 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/environmentTypes/{environmentTypeName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "environmentTypeName": _SERIALIZER.url("environment_type_name", environment_type_name, "str"), } @@ -177,7 +198,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,8 +209,10 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/environmentTypes/{environmentTypeName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "environmentTypeName": _SERIALIZER.url("environment_type_name", environment_type_name, "str"), } @@ -209,7 +234,7 @@ class ProjectEnvironmentTypesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`project_environment_types` attribute. """ @@ -228,7 +253,8 @@ def list( ) -> Iterable["_models.ProjectEnvironmentType"]: """Lists environment types for a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -244,7 +270,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ProjectEnvironmentTypeListResult] error_map = { @@ -273,10 +301,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -313,7 +348,8 @@ def get( ) -> _models.ProjectEnvironmentType: """Gets a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -335,7 +371,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ProjectEnvironmentType] request = build_get_request( @@ -383,7 +421,8 @@ def create_or_update( ) -> _models.ProjectEnvironmentType: """Creates or updates a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -413,7 +452,8 @@ def create_or_update( ) -> _models.ProjectEnvironmentType: """Creates or updates a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -441,7 +481,8 @@ def create_or_update( ) -> _models.ProjectEnvironmentType: """Creates or updates a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -469,7 +510,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.ProjectEnvironmentType] @@ -529,7 +572,8 @@ def update( ) -> _models.ProjectEnvironmentType: """Partially updates a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -559,7 +603,8 @@ def update( ) -> _models.ProjectEnvironmentType: """Partially updates a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -587,7 +632,8 @@ def update( ) -> _models.ProjectEnvironmentType: """Partially updates a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -615,7 +661,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.ProjectEnvironmentType] @@ -668,7 +716,8 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a project environment type. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -690,7 +739,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_projects_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_projects_operations.py index e67041483fb9..fe132050a0b8 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_projects_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_projects_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,13 +49,15 @@ def build_list_by_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DevCenter/projects") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) @@ -72,7 +79,9 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,8 +90,10 @@ def build_list_by_resource_group_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", 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) @@ -102,7 +113,9 @@ def build_get_request(resource_group_name: str, project_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -111,8 +124,10 @@ def build_get_request(resource_group_name: str, project_name: str, subscription_ "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), } @@ -133,7 +148,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -143,8 +160,10 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), } @@ -167,7 +186,9 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -177,8 +198,10 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), } @@ -201,7 +224,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -210,8 +235,10 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), } @@ -232,7 +259,7 @@ class ProjectsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`projects` attribute. """ @@ -260,7 +287,9 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ProjectListResult] error_map = { @@ -287,10 +316,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -327,7 +363,8 @@ def list_by_resource_group( ) -> Iterable["_models.Project"]: """Lists all projects in the resource group. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param top: The maximum number of resources to return from the operation. Example: '$top=10'. Default value is None. @@ -340,7 +377,9 @@ def list_by_resource_group( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ProjectListResult] error_map = { @@ -368,10 +407,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -406,7 +452,8 @@ def get_next(next_link=None): def get(self, resource_group_name: str, project_name: str, **kwargs: Any) -> _models.Project: """Gets a specific project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -426,7 +473,9 @@ def get(self, resource_group_name: str, project_name: str, **kwargs: Any) -> _mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Project] request = build_get_request( @@ -474,7 +523,9 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Project] @@ -536,7 +587,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Project]: """Creates or updates a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -570,7 +622,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Project]: """Creates or updates a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -598,7 +651,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Project]: """Creates or updates a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -622,7 +676,9 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Project] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -681,7 +737,9 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Project]] @@ -741,7 +799,8 @@ def begin_update( ) -> LROPoller[_models.Project]: """Partially updates a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -775,7 +834,8 @@ def begin_update( ) -> LROPoller[_models.Project]: """Partially updates a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -803,7 +863,8 @@ def begin_update( ) -> LROPoller[_models.Project]: """Partially updates a project. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -827,7 +888,9 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Project] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -886,7 +949,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -920,7 +985,8 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements def begin_delete(self, resource_group_name: str, project_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a project resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -939,7 +1005,9 @@ def begin_delete(self, resource_group_name: str, project_name: str, **kwargs: An _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_schedules_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_schedules_operations.py index 74e8de5702f4..8ca92a1820a5 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_schedules_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_schedules_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +55,9 @@ def build_list_by_pool_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,8 +66,10 @@ def build_list_by_pool_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}/schedules", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "poolName": _SERIALIZER.url("pool_name", pool_name, "str"), } @@ -91,7 +100,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -100,8 +111,10 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "poolName": _SERIALIZER.url("pool_name", pool_name, "str"), "scheduleName": _SERIALIZER.url( @@ -135,7 +148,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -145,8 +160,10 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "poolName": _SERIALIZER.url("pool_name", pool_name, "str"), "scheduleName": _SERIALIZER.url( @@ -182,7 +199,9 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -192,8 +211,10 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "poolName": _SERIALIZER.url("pool_name", pool_name, "str"), "scheduleName": _SERIALIZER.url( @@ -229,7 +250,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -238,8 +261,10 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "poolName": _SERIALIZER.url("pool_name", pool_name, "str"), "scheduleName": _SERIALIZER.url( @@ -266,7 +291,7 @@ class SchedulesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`schedules` attribute. """ @@ -285,7 +310,8 @@ def list_by_pool( ) -> Iterable["_models.Schedule"]: """Lists schedules for a pool. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -302,7 +328,9 @@ def list_by_pool( _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduleListResult] error_map = { @@ -332,10 +360,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -378,7 +413,8 @@ def get( ) -> _models.Schedule: """Gets a schedule resource. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -405,7 +441,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Schedule] request = build_get_request( @@ -463,7 +501,9 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Schedule] @@ -499,11 +539,15 @@ def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [201]: + 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) - deserialized = self._deserialize("Schedule", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("Schedule", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Schedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -527,7 +571,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Schedule]: """Creates or updates a Schedule. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -571,7 +616,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Schedule]: """Creates or updates a Schedule. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -613,7 +659,8 @@ def begin_create_or_update( ) -> LROPoller[_models.Schedule]: """Creates or updates a Schedule. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -644,7 +691,9 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Schedule] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -692,7 +741,7 @@ def get_long_running_output(pipeline_response): begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}"} # type: ignore - def _update_initial( # pylint: disable=inconsistent-return-statements + def _update_initial( self, resource_group_name: str, project_name: str, @@ -701,7 +750,7 @@ def _update_initial( # pylint: disable=inconsistent-return-statements body: Union[_models.ScheduleUpdate, IO], top: Optional[int] = None, **kwargs: Any - ) -> None: + ) -> Optional[_models.Schedule]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -713,9 +762,11 @@ def _update_initial( # pylint: disable=inconsistent-return-statements _headers = case_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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Schedule]] content_type = content_type or "application/json" _json = None @@ -749,12 +800,18 @@ def _update_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Schedule", pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + + return deserialized _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}"} # type: ignore @@ -770,10 +827,11 @@ def begin_update( *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: + ) -> LROPoller[_models.Schedule]: """Partially updates a Scheduled. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -797,8 +855,8 @@ def begin_update( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: 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] + :return: An instance of LROPoller that returns either Schedule or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.devcenter.models.Schedule] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -814,10 +872,11 @@ def begin_update( *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: + ) -> LROPoller[_models.Schedule]: """Partially updates a Scheduled. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -841,8 +900,8 @@ def begin_update( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: 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] + :return: An instance of LROPoller that returns either Schedule or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.devcenter.models.Schedule] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -856,10 +915,11 @@ def begin_update( body: Union[_models.ScheduleUpdate, IO], top: Optional[int] = None, **kwargs: Any - ) -> LROPoller[None]: + ) -> LROPoller[_models.Schedule]: """Partially updates a Scheduled. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -883,16 +943,18 @@ def begin_update( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: 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] + :return: An instance of LROPoller that returns either Schedule or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.devcenter.models.Schedule] :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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Schedule] 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] @@ -913,9 +975,11 @@ def begin_update( ) kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Schedule", pipeline_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + return deserialized if polling is True: polling_method = cast( @@ -956,7 +1020,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -1001,7 +1067,8 @@ def begin_delete( ) -> LROPoller[None]: """Deletes a Scheduled. - :param resource_group_name: Name of the resource group within the Azure subscription. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param project_name: The name of the project. Required. :type project_name: str @@ -1027,7 +1094,9 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] 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) diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_skus_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_skus_operations.py index 6756ac97d197..70ff70cfb45a 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_skus_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_skus_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,13 +47,15 @@ def build_list_by_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DevCenter/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) @@ -70,7 +77,7 @@ class SkusOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`skus` attribute. """ @@ -98,7 +105,9 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SkuListResult] error_map = { @@ -125,10 +134,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" diff --git a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_usages_operations.py b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_usages_operations.py index ee9b8a9bed3a..ee9309734cc6 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_usages_operations.py +++ b/sdk/devcenter/azure-mgmt-devcenter/azure/mgmt/devcenter/operations/_usages_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_by_location_request(location: str, subscription_id: str, **kwargs _headers = case_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-09-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-10-12-preview") + ) # type: Literal["2022-10-12-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -48,7 +55,7 @@ def build_list_by_location_request(location: str, subscription_id: str, **kwargs "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DevCenter/locations/{location}/usages" ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "location": _SERIALIZER.url("location", location, "str"), } @@ -69,7 +76,7 @@ class UsagesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.devcenter.DevCenterClient`'s + :class:`~azure.mgmt.devcenter.DevCenterMgmtClient`'s :attr:`usages` attribute. """ @@ -96,7 +103,9 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us _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 + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-10-12-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ListUsagesResult] error_map = { @@ -123,10 +132,17 @@ def prepare_request(next_link=None): 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)) + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_create.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_create.py new file mode 100644 index 000000000000..ba57524a604e --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_create.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python attached_networks_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.attached_networks.begin_create_or_update( + resource_group_name="rg1", + dev_center_name="Contoso", + attached_network_connection_name="{attachedNetworkConnectionName}", + body={ + "properties": { + "networkConnectionId": "/subscriptions/{subscriptionId}/resourceGroups/rg1/providers/Microsoft.DevCenter/NetworkConnections/network-uswest3" + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/AttachedNetworks_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_delete.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_delete.py new file mode 100644 index 000000000000..90621debecad --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python attached_networks_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.attached_networks.begin_delete( + resource_group_name="rg1", + dev_center_name="Contoso", + attached_network_connection_name="{attachedNetworkConnectionName}", + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/AttachedNetworks_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_get_by_dev_center.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_get_by_dev_center.py new file mode 100644 index 000000000000..58c600229f57 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_get_by_dev_center.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python attached_networks_get_by_dev_center.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.attached_networks.get_by_dev_center( + resource_group_name="rg1", + dev_center_name="Contoso", + attached_network_connection_name="network-uswest3", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/AttachedNetworks_GetByDevCenter.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_get_by_project.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_get_by_project.py new file mode 100644 index 000000000000..338c559f2829 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_get_by_project.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python attached_networks_get_by_project.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.attached_networks.get_by_project( + resource_group_name="rg1", + project_name="{projectName}", + attached_network_connection_name="network-uswest3", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/AttachedNetworks_GetByProject.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_list_by_dev_center.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_list_by_dev_center.py new file mode 100644 index 000000000000..a92831685a5e --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_list_by_dev_center.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python attached_networks_list_by_dev_center.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.attached_networks.list_by_dev_center( + resource_group_name="rg1", + dev_center_name="Contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/AttachedNetworks_ListByDevCenter.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_list_by_project.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_list_by_project.py new file mode 100644 index 000000000000..b0d4785329eb --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/attached_networks_list_by_project.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python attached_networks_list_by_project.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.attached_networks.list_by_project( + resource_group_name="rg1", + project_name="{projectName}", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/AttachedNetworks_ListByProject.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_create_or_update_ado.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_create_or_update_ado.py new file mode 100644 index 000000000000..693510679f36 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_create_or_update_ado.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python catalogs_create_or_update_ado.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.catalogs.begin_create_or_update( + resource_group_name="rg1", + dev_center_name="Contoso", + catalog_name="{catalogName}", + body={ + "properties": { + "adoGit": { + "branch": "main", + "path": "/templates", + "secretIdentifier": "https://contosokv.vault.azure.net/secrets/CentralRepoPat", + "uri": "https://contoso@dev.azure.com/contoso/contosoOrg/_git/centralrepo-fakecontoso", + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Catalogs_CreateAdo.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_create_or_update_git_hub.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_create_or_update_git_hub.py new file mode 100644 index 000000000000..76d92d3d5276 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_create_or_update_git_hub.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python catalogs_create_or_update_git_hub.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.catalogs.begin_create_or_update( + resource_group_name="rg1", + dev_center_name="Contoso", + catalog_name="{catalogName}", + body={ + "properties": { + "gitHub": { + "branch": "main", + "path": "/templates", + "secretIdentifier": "https://contosokv.vault.azure.net/secrets/CentralRepoPat", + "uri": "https://github.com/Contoso/centralrepo-fake.git", + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Catalogs_CreateGitHub.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_delete.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_delete.py new file mode 100644 index 000000000000..bb57c247624a --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python catalogs_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.catalogs.begin_delete( + resource_group_name="rg1", + dev_center_name="Contoso", + catalog_name="{catalogName}", + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Catalogs_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_get.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_get.py new file mode 100644 index 000000000000..6a23c579326f --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python catalogs_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.catalogs.get( + resource_group_name="rg1", + dev_center_name="Contoso", + catalog_name="{catalogName}", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Catalogs_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_list_by_dev_center.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_list_by_dev_center.py new file mode 100644 index 000000000000..6b61e6157254 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_list_by_dev_center.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python catalogs_list_by_dev_center.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.catalogs.list_by_dev_center( + resource_group_name="rg1", + dev_center_name="Contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Catalogs_List.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_sync.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_sync.py new file mode 100644 index 000000000000..5af965487df1 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_sync.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python catalogs_sync.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.catalogs.begin_sync( + resource_group_name="rg1", + dev_center_name="Contoso", + catalog_name="{catalogName}", + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Catalogs_Sync.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_update.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_update.py new file mode 100644 index 000000000000..5fb99fbaef98 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/catalogs_update.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python catalogs_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.catalogs.begin_update( + resource_group_name="rg1", + dev_center_name="Contoso", + catalog_name="{catalogName}", + body={"properties": {"gitHub": {"path": "/environments"}}}, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Catalogs_Patch.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_create.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_create.py new file mode 100644 index 000000000000..895fcbda0af4 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_create.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python dev_box_definitions_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.dev_box_definitions.begin_create_or_update( + resource_group_name="rg1", + dev_center_name="Contoso", + dev_box_definition_name="WebDevBox", + body={ + "location": "centralus", + "properties": { + "imageReference": { + "id": "/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/Example/providers/Microsoft.DevCenter/devcenters/Contoso/galleries/contosogallery/images/exampleImage/version/1.0.0" + }, + "osStorageType": "SSD_1024", + "sku": {"name": "Preview"}, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/DevBoxDefinitions_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_delete.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_delete.py new file mode 100644 index 000000000000..c486c375abc9 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python dev_box_definitions_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.dev_box_definitions.begin_delete( + resource_group_name="rg1", + dev_center_name="Contoso", + dev_box_definition_name="WebDevBox", + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/DevBoxDefinitions_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_get.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_get.py new file mode 100644 index 000000000000..777079fb69ef --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python dev_box_definitions_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.dev_box_definitions.get( + resource_group_name="rg1", + dev_center_name="Contoso", + dev_box_definition_name="WebDevBox", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/DevBoxDefinitions_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_get_by_project.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_get_by_project.py new file mode 100644 index 000000000000..df2bce844089 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_get_by_project.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python dev_box_definitions_get_by_project.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.dev_box_definitions.get_by_project( + resource_group_name="rg1", + project_name="ContosoProject", + dev_box_definition_name="WebDevBox", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/DevBoxDefinitions_GetByProject.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_list_by_dev_center.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_list_by_dev_center.py new file mode 100644 index 000000000000..a2d29e83867b --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_list_by_dev_center.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python dev_box_definitions_list_by_dev_center.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.dev_box_definitions.list_by_dev_center( + resource_group_name="rg1", + dev_center_name="Contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/DevBoxDefinitions_ListByDevCenter.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_list_by_project.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_list_by_project.py new file mode 100644 index 000000000000..6f7b52e1142c --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_list_by_project.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python dev_box_definitions_list_by_project.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.dev_box_definitions.list_by_project( + resource_group_name="rg1", + project_name="ContosoProject", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/DevBoxDefinitions_ListByProject.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_patch.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_patch.py new file mode 100644 index 000000000000..135bc304c3cf --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_box_definitions_patch.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python dev_box_definitions_patch.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.dev_box_definitions.begin_update( + resource_group_name="rg1", + dev_center_name="Contoso", + dev_box_definition_name="WebDevBox", + body={ + "properties": { + "imageReference": { + "id": "/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/Example/providers/Microsoft.DevCenter/devcenters/Contoso/galleries/contosogallery/images/exampleImage/version/2.0.0" + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/DevBoxDefinitions_Patch.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_create.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_create.py new file mode 100644 index 000000000000..32472e630526 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_create.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python dev_centers_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.dev_centers.begin_create_or_update( + resource_group_name="rg1", + dev_center_name="Contoso", + body={"location": "centralus", "properties": {}, "tags": {"CostCode": "12345"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/DevCenters_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_create_with_user_identity.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_create_with_user_identity.py new file mode 100644 index 000000000000..9b0ad4bff8dc --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_create_with_user_identity.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python dev_centers_create_with_user_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.dev_centers.begin_create_or_update( + resource_group_name="rg1", + dev_center_name="Contoso", + body={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/identityGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity1": {} + }, + }, + "location": "centralus", + "properties": {}, + "tags": {"CostCode": "12345"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/DevCenters_CreateWithUserIdentity.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_delete.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_delete.py new file mode 100644 index 000000000000..7396caa505ba --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python dev_centers_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.dev_centers.begin_delete( + resource_group_name="rg1", + dev_center_name="Contoso", + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/DevCenters_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_get.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_get.py new file mode 100644 index 000000000000..78b54d8274de --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_get.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python dev_centers_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.dev_centers.get( + resource_group_name="rg1", + dev_center_name="Contoso", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/DevCenters_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_list_by_resource_group.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_list_by_resource_group.py new file mode 100644 index 000000000000..5efabba13934 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_list_by_resource_group.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python dev_centers_list_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.dev_centers.list_by_resource_group( + resource_group_name="rg1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/DevCenters_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_list_by_subscription.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_list_by_subscription.py new file mode 100644 index 000000000000..a33944536329 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_list_by_subscription.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python dev_centers_list_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.dev_centers.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/DevCenters_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_update.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_update.py new file mode 100644 index 000000000000..89922af556c8 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/dev_centers_update.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python dev_centers_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.dev_centers.begin_update( + resource_group_name="rg1", + dev_center_name="Contoso", + body={"tags": {"CostCode": "12345"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/DevCenters_Patch.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_create_or_update.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_create_or_update.py new file mode 100644 index 000000000000..33eb5f1e1cc7 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_create_or_update.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python environment_types_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.environment_types.create_or_update( + resource_group_name="rg1", + dev_center_name="Contoso", + environment_type_name="{environmentTypeName}", + body={"tags": {"Owner": "superuser"}}, + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/EnvironmentTypes_Put.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_delete.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_delete.py new file mode 100644 index 000000000000..6170a008c4a7 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python environment_types_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.environment_types.delete( + resource_group_name="rg1", + dev_center_name="Contoso", + environment_type_name="{environmentTypeName}", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/EnvironmentTypes_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_get.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_get.py new file mode 100644 index 000000000000..f2c573f6f20b --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python environment_types_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.environment_types.get( + resource_group_name="rg1", + dev_center_name="Contoso", + environment_type_name="{environmentTypeName}", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/EnvironmentTypes_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_list_by_dev_center.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_list_by_dev_center.py new file mode 100644 index 000000000000..d89381da1ae5 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_list_by_dev_center.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python environment_types_list_by_dev_center.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.environment_types.list_by_dev_center( + resource_group_name="rg1", + dev_center_name="Contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/EnvironmentTypes_List.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_update.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_update.py new file mode 100644 index 000000000000..8b031e2733fe --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/environment_types_update.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python environment_types_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.environment_types.update( + resource_group_name="rg1", + dev_center_name="Contoso", + environment_type_name="{environmentTypeName}", + body={"tags": {"Owner": "superuser"}}, + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/EnvironmentTypes_Patch.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/galleries_create_or_update.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/galleries_create_or_update.py new file mode 100644 index 000000000000..adf5d2281cca --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/galleries_create_or_update.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python galleries_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.galleries.begin_create_or_update( + resource_group_name="rg1", + dev_center_name="Contoso", + gallery_name="{galleryName}", + body={ + "properties": { + "galleryResourceId": "/subscriptions/{subscriptionId}/resourceGroups/rg1/providers/Microsoft.Compute/galleries/{galleryName}" + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Galleries_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/galleries_delete.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/galleries_delete.py new file mode 100644 index 000000000000..ee416b470ca0 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/galleries_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python galleries_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.galleries.begin_delete( + resource_group_name="rg1", + dev_center_name="Contoso", + gallery_name="{galleryName}", + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Galleries_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/galleries_get.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/galleries_get.py new file mode 100644 index 000000000000..b6d9f0541f0d --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/galleries_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python galleries_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.galleries.get( + resource_group_name="rg1", + dev_center_name="Contoso", + gallery_name="{galleryName}", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Galleries_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/galleries_list_by_dev_center.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/galleries_list_by_dev_center.py new file mode 100644 index 000000000000..15a4ebc5e139 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/galleries_list_by_dev_center.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python galleries_list_by_dev_center.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.galleries.list_by_dev_center( + resource_group_name="rg1", + dev_center_name="Contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Galleries_List.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/get_operation_status.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/get_operation_status.py new file mode 100644 index 000000000000..1d5bb4ef1a60 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/get_operation_status.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python get_operation_status.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.operation_statuses.get( + location="{location}", + operation_id="{operationId}", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/OperationStatus_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/image_versions_list_by_image.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/image_versions_list_by_image.py new file mode 100644 index 000000000000..7c190abd5ecf --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/image_versions_list_by_image.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python image_versions_list_by_image.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.image_versions.list_by_image( + resource_group_name="rg1", + dev_center_name="Contoso", + gallery_name="DefaultDevGallery", + image_name="Win11", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/ImageVersions_List.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/images_get.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/images_get.py new file mode 100644 index 000000000000..bfe4ef0a5b53 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/images_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python images_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.images.get( + resource_group_name="rg1", + dev_center_name="Contoso", + gallery_name="DefaultDevGallery", + image_name="{imageName}", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Images_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/images_list_by_dev_center.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/images_list_by_dev_center.py new file mode 100644 index 000000000000..718fb654b670 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/images_list_by_dev_center.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python images_list_by_dev_center.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.images.list_by_dev_center( + resource_group_name="rg1", + dev_center_name="Contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Images_ListByDevCenter.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/images_list_by_gallery.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/images_list_by_gallery.py new file mode 100644 index 000000000000..408ba54dfc95 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/images_list_by_gallery.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python images_list_by_gallery.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.images.list_by_gallery( + resource_group_name="rg1", + dev_center_name="Contoso", + gallery_name="DevGallery", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Images_ListByGallery.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/list_usages.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/list_usages.py new file mode 100644 index 000000000000..57b5d42c25c5 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/list_usages.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python list_usages.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.usages.list_by_location( + location="westus", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Usages_ListByLocation.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_create_or_update.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_create_or_update.py new file mode 100644 index 000000000000..a06884d8f03e --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_create_or_update.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python network_connections_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.network_connections.begin_create_or_update( + resource_group_name="rg1", + network_connection_name="uswest3network", + body={ + "location": "centralus", + "properties": { + "domainJoinType": "HybridAzureADJoin", + "domainName": "mydomaincontroller.local", + "domainPassword": "Password value for user", + "domainUsername": "testuser@mydomaincontroller.local", + "networkingResourceGroupName": "NetworkInterfaces", + "subnetId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ExampleRG/providers/Microsoft.Network/virtualNetworks/ExampleVNet/subnets/default", + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/NetworkConnections_Put.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_delete.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_delete.py new file mode 100644 index 000000000000..15923a792795 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python network_connections_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.network_connections.begin_delete( + resource_group_name="rg1", + network_connection_name="{networkConnectionName}", + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/NetworkConnections_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_get.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_get.py new file mode 100644 index 000000000000..d723a58eb8b0 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_get.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python network_connections_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.network_connections.get( + resource_group_name="rg1", + network_connection_name="uswest3network", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/NetworkConnections_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_get_health_details.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_get_health_details.py new file mode 100644 index 000000000000..55c1aa83ed7b --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_get_health_details.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python network_connections_get_health_details.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.network_connections.get_health_details( + resource_group_name="rg1", + network_connection_name="{networkConnectionName}", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/NetworkConnections_GetHealthDetails.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_list_by_resource_group.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_list_by_resource_group.py new file mode 100644 index 000000000000..c8be5ea3b982 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_list_by_resource_group.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python network_connections_list_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.network_connections.list_by_resource_group( + resource_group_name="rg1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/NetworkConnections_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_list_by_subscription.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_list_by_subscription.py new file mode 100644 index 000000000000..a460a6c9f587 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_list_by_subscription.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python network_connections_list_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.network_connections.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/NetworkConnections_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_list_health_details.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_list_health_details.py new file mode 100644 index 000000000000..b4496a13dd3b --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_list_health_details.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python network_connections_list_health_details.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.network_connections.list_health_details( + resource_group_name="rg1", + network_connection_name="uswest3network", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/NetworkConnections_ListHealthDetails.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_run_health_checks.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_run_health_checks.py new file mode 100644 index 000000000000..40418f84c41f --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_run_health_checks.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python network_connections_run_health_checks.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.network_connections.run_health_checks( + resource_group_name="rg1", + network_connection_name="uswest3network", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/NetworkConnections_RunHealthChecks.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_update.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_update.py new file mode 100644 index 000000000000..1b6fa8171845 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/network_connections_update.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python network_connections_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.network_connections.begin_update( + resource_group_name="rg1", + network_connection_name="uswest3network", + body={"properties": {"domainPassword": "New Password value for user"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/NetworkConnections_Patch.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/operations_get.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/operations_get.py new file mode 100644 index 000000000000..c96a6191c539 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/operations_get.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python operations_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Operations_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_create_or_update.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_create_or_update.py new file mode 100644 index 000000000000..308d6d32fd4d --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_create_or_update.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python pools_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.pools.begin_create_or_update( + resource_group_name="rg1", + project_name="{projectName}", + pool_name="{poolName}", + body={ + "location": "centralus", + "properties": { + "devBoxDefinitionName": "WebDevBox", + "licenseType": "Windows_Client", + "localAdministrator": "Enabled", + "networkConnectionName": "Network1-westus2", + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Pools_Put.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_delete.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_delete.py new file mode 100644 index 000000000000..2fd199b22e90 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python pools_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.pools.begin_delete( + resource_group_name="rg1", + project_name="{projectName}", + pool_name="poolName", + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Pools_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_get.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_get.py new file mode 100644 index 000000000000..036559e76a79 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python pools_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.pools.get( + resource_group_name="rg1", + project_name="{projectName}", + pool_name="{poolName}", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Pools_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_list_by_project.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_list_by_project.py new file mode 100644 index 000000000000..4aa1ae688cf6 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_list_by_project.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python pools_list_by_project.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.pools.list_by_project( + resource_group_name="rg1", + project_name="{projectName}", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Pools_List.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_update.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_update.py new file mode 100644 index 000000000000..193ed1a94e53 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/pools_update.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python pools_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.pools.begin_update( + resource_group_name="rg1", + project_name="{projectName}", + pool_name="{poolName}", + body={"properties": {"devBoxDefinitionName": "WebDevBox2"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Pools_Patch.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_allowed_environment_types_get.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_allowed_environment_types_get.py new file mode 100644 index 000000000000..9c28e4ac0033 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_allowed_environment_types_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python project_allowed_environment_types_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.project_allowed_environment_types.get( + resource_group_name="rg1", + project_name="Contoso", + environment_type_name="{environmentTypeName}", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/ProjectAllowedEnvironmentTypes_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_allowed_environment_types_list.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_allowed_environment_types_list.py new file mode 100644 index 000000000000..8f6ae3cab28d --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_allowed_environment_types_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python project_allowed_environment_types_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.project_allowed_environment_types.list( + resource_group_name="rg1", + project_name="Contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/ProjectAllowedEnvironmentTypes_List.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_create_or_update.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_create_or_update.py new file mode 100644 index 000000000000..7875f3835e3a --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_create_or_update.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python project_environment_types_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.project_environment_types.create_or_update( + resource_group_name="rg1", + project_name="ContosoProj", + environment_type_name="{environmentTypeName}", + body={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/identityGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity1": {} + }, + }, + "properties": { + "creatorRoleAssignment": {"roles": {"4cbf0b6c-e750-441c-98a7-10da8387e4d6": {}}}, + "deploymentTargetId": "/subscriptions/00000000-0000-0000-0000-000000000000", + "status": "Enabled", + "userRoleAssignments": { + "e45e3m7c-176e-416a-b466-0c5ec8298f8a": {"roles": {"4cbf0b6c-e750-441c-98a7-10da8387e4d6": {}}} + }, + }, + "tags": {"CostCenter": "RnD"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/ProjectEnvironmentTypes_Put.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_delete.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_delete.py new file mode 100644 index 000000000000..66f570f9b07a --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python project_environment_types_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.project_environment_types.delete( + resource_group_name="rg1", + project_name="ContosoProj", + environment_type_name="{environmentTypeName}", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/ProjectEnvironmentTypes_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_get.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_get.py new file mode 100644 index 000000000000..672da85e353b --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python project_environment_types_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.project_environment_types.get( + resource_group_name="rg1", + project_name="ContosoProj", + environment_type_name="{environmentTypeName}", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/ProjectEnvironmentTypes_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_list.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_list.py new file mode 100644 index 000000000000..6e632312961e --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python project_environment_types_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.project_environment_types.list( + resource_group_name="rg1", + project_name="ContosoProj", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/ProjectEnvironmentTypes_List.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_update.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_update.py new file mode 100644 index 000000000000..5f84dddff4a1 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/project_environment_types_update.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python project_environment_types_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.project_environment_types.update( + resource_group_name="rg1", + project_name="ContosoProj", + environment_type_name="{environmentTypeName}", + body={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/identityGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity1": {} + }, + }, + "properties": { + "deploymentTargetId": "/subscriptions/00000000-0000-0000-0000-000000000000", + "status": "Enabled", + "userRoleAssignments": { + "e45e3m7c-176e-416a-b466-0c5ec8298f8a": {"roles": {"4cbf0b6c-e750-441c-98a7-10da8387e4d6": {}}} + }, + }, + "tags": {"CostCenter": "RnD"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/ProjectEnvironmentTypes_Patch.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_create_or_update.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_create_or_update.py new file mode 100644 index 000000000000..f996b7bc43a5 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_create_or_update.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python projects_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.projects.begin_create_or_update( + resource_group_name="rg1", + project_name="{projectName}", + body={ + "location": "centralus", + "properties": { + "description": "This is my first project.", + "devCenterId": "/subscriptions/{subscriptionId}/resourceGroups/rg1/providers/Microsoft.DevCenter/devcenters/{devCenterName}", + }, + "tags": {"CostCenter": "R&D"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Projects_Put.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_delete.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_delete.py new file mode 100644 index 000000000000..8b8f431179d2 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python projects_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.projects.begin_delete( + resource_group_name="rg1", + project_name="{projectName}", + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Projects_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_get.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_get.py new file mode 100644 index 000000000000..946e5ae57847 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_get.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python projects_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.projects.get( + resource_group_name="rg1", + project_name="{projectName}", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Projects_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_list_by_resource_group.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_list_by_resource_group.py new file mode 100644 index 000000000000..d8cca00b8c22 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_list_by_resource_group.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python projects_list_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.projects.list_by_resource_group( + resource_group_name="rg1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Projects_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_list_by_subscription.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_list_by_subscription.py new file mode 100644 index 000000000000..c751e0453eaa --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_list_by_subscription.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python projects_list_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.projects.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Projects_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_update.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_update.py new file mode 100644 index 000000000000..915dc8c2e59e --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/projects_update.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python projects_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.projects.begin_update( + resource_group_name="rg1", + project_name="{projectName}", + body={"properties": {"description": "This is my first project."}, "tags": {"CostCenter": "R&D"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Projects_Patch.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_create_daily_shutdown_pool_schedule.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_create_daily_shutdown_pool_schedule.py new file mode 100644 index 000000000000..793afa9a52db --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_create_daily_shutdown_pool_schedule.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python schedules_create_daily_shutdown_pool_schedule.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.schedules.begin_create_or_update( + resource_group_name="rg1", + project_name="DevProject", + pool_name="DevPool", + schedule_name="autoShutdown", + body={ + "properties": { + "frequency": "Daily", + "state": "Enabled", + "time": "17:30", + "timeZone": "America/Los_Angeles", + "type": "StopDevBox", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Schedules_CreateDailyShutdownPoolSchedule.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_delete.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_delete.py new file mode 100644 index 000000000000..884a2dd883a9 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_delete.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python schedules_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.schedules.begin_delete( + resource_group_name="rg1", + project_name="TestProject", + pool_name="DevPool", + schedule_name="autoShutdown", + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Schedules_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_get_by_pool.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_get_by_pool.py new file mode 100644 index 000000000000..8a1ebc94cd60 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_get_by_pool.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python schedules_get_by_pool.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.schedules.get( + resource_group_name="rg1", + project_name="TestProject", + pool_name="DevPool", + schedule_name="autoShutdown", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Schedules_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_list_by_pool.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_list_by_pool.py new file mode 100644 index 000000000000..714153239c30 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_list_by_pool.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python schedules_list_by_pool.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.schedules.list_by_pool( + resource_group_name="rg1", + project_name="TestProject", + pool_name="DevPool", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Schedules_ListByPool.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_update.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_update.py new file mode 100644 index 000000000000..ac9ea8eb1c81 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/schedules_update.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python schedules_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.schedules.begin_update( + resource_group_name="rg1", + project_name="TestProject", + pool_name="DevPool", + schedule_name="autoShutdown", + body={"properties": {"time": "18:00"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Schedules_Patch.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/skus_list_by_subscription.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/skus_list_by_subscription.py new file mode 100644 index 000000000000..96975b1ca154 --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/skus_list_by_subscription.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python skus_list_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.skus.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/Skus_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/generated_samples/versions_get.py b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/versions_get.py new file mode 100644 index 000000000000..377f9a64777c --- /dev/null +++ b/sdk/devcenter/azure-mgmt-devcenter/generated_samples/versions_get.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.devcenter import DevCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devcenter +# USAGE + python versions_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.image_versions.get( + resource_group_name="rg1", + dev_center_name="Contoso", + gallery_name="DefaultDevGallery", + image_name="Win11", + version_name="{versionName}", + ) + print(response) + + +# x-ms-original-file: specification/devcenter/resource-manager/Microsoft.DevCenter/preview/2022-10-12-preview/examples/ImageVersions_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devcenter/azure-mgmt-devcenter/setup.py b/sdk/devcenter/azure-mgmt-devcenter/setup.py index 24808ff236ba..3a1fcdb09650 100644 --- a/sdk/devcenter/azure-mgmt-devcenter/setup.py +++ b/sdk/devcenter/azure-mgmt-devcenter/setup.py @@ -55,6 +55,7 @@ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'License :: OSI Approved :: MIT License', ], zip_safe=False, @@ -69,9 +70,10 @@ 'pytyped': ['py.typed'], }, install_requires=[ - 'msrest>=0.7.1', - 'azure-common~=1.1', - 'azure-mgmt-core>=1.3.2,<2.0.0', + "msrest>=0.7.1", + "azure-common~=1.1", + "azure-mgmt-core>=1.3.2,<2.0.0", + "typing-extensions>=4.3.0; python_version<'3.8.0'", ], python_requires=">=3.7" ) diff --git a/shared_requirements.txt b/shared_requirements.txt index 35ee4ba9ab3d..99f591b4fb33 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -190,6 +190,7 @@ yarl<2.0,>=1.0 #override azure-storage-queue azure-core<2.0.0,>=1.26.0 #override azure-storage-queue azure-core[aio]<2.0.0,>=1.26.0 #override azure-storage-queue typing-extensions>=4.0.1 +#override azure-mgmt-devcenter typing-extensions>=4.3.0; python_version<'3.8.0' #override azure-storage-queue isodate>=0.6.1 #override azure-storage-file-share azure-core<2.0.0,>=1.26.0 #override azure-storage-file-share azure-core[aio]<2.0.0,>=1.26.0